CoreBOSBB
To be alerted when new user is created - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17)
+--- Forum: User Support (https://discussions.corebos.org/forumdisplay.php?fid=6)
+--- Thread: To be alerted when new user is created (/showthread.php?tid=1556)



To be alerted when new user is created - geraldbigot - 08-20-2019

Hello,

Is someone could help me creating such a workflow :
Condition : as soon as a new user is created in CRM
Action : send email to special email

Thank you

Gérald


RE: To be alerted when new user is created - joebordes - 08-21-2019

The user module does not support events nor workflows so the only way is adding your email directly. This could be an interesting coreBOS OnDemand feature, but, for the moment, you have to hard code it.


How to send an email is explained with a lot of detail in the blog and wiki. You have to add your email either here:

https://github.com/tsolucio/corebos/blob/master/modules/Users/Save.php#L190

right after the welcome email the system sends, or here:

https://github.com/tsolucio/corebos/blob/master/modules/Users/Users.php#L1152

right before the coreBOS OnDemand user log creation.

keep asking


RE: To be alerted when new user is created - geraldbigot - 08-22-2019

THank you.
I will try the first method.

Gérald

(08-21-2019, 10:18 PM)joebordes Wrote: The user module does not support events nor workflows so the only way is adding your email directly. This could be an interesting coreBOS OnDemand feature, but, for the moment, you have to hard code it.


How to send an email is explained with a lot of detail in the blog and wiki. You have to add your email either here:

https://github.com/tsolucio/corebos/blob/master/modules/Users/Save.php#L190

right after the welcome email the system sends, or here:



RE: To be alerted when new user is created - joebordes - 08-22-2019

let us know how it goes


RE: To be alerted when new user is created - geraldbigot - 08-27-2019

(08-22-2019, 09:09 AM)joebordes Wrote: let us know how it goes

Hello,

Everything is fine with this method (just after l190 in Save.php) :


Code:
include_once 'vtlib/Vtiger/Module.php';
include_once 'modules/Emails/mail.php';
$current_user = Users::getActiveAdminUser();
$to_email = 'to@somedomain.tld';
$from_name = 'Company/User name';
$from_email = 'from@yourdomain.tld';
$subject = 'Email Subject';
$content = 'Email Content';
$accountid = vtws_getEntityId('Accounts').'x74'; // 74 is an account ID in the coreBOS Tests database
$email = array(
   'saved_toid' => $to_email,
   'parent_type' => 'Accounts',
   'parent_id' => $accountid,
   'from_email' => $from_email,
   'subject' => $subject,
   'description' => $content,
);
$wsemailid = createEmailRecord($email);
list($emwsid, $emailid) = explode('x', $wsemailid);

$rdo = send_mail('HelpDesk', $to_email, $from_name, $from_email, $subject, $content, '', '', array(), $emailid);
if ($rdo != 0) {
   // Delete the $emailid record
   $focus = CRMEntity::getInstance('Emails');
   DeleteEntity('Emails', 'Emails', $focus, $emailid, $emailid);
}

Thank you.


RE: To be alerted when new user is created - joebordes - 08-28-2019

:-)