- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 07:37 PM - edited ‎11-22-2022 08:53 PM
I am Creating Inbound email action and creating case Record.
After creating if the inbound email Domain is (eg,gmail.com).
the particular Account record with the (gmail.com ) to be selected and stored in Account field in that case Record, i have created the Script but it is not getting updated in the Case record, but in the Logs it is currectly giving the output.
suggest me what changes do i need to do
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 04:17 AM
Please check the below code:-
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
current.u_insp_email = email.from;
var domain = email.from.split('@')[1];
gs.info("Name is: " + domain);
var gr = new GlideRecord('customer_account');
gr.addEncodedQuery('u_emailidCONTAINS' + domain);
gr.query();
if (gr.next()) {
current.account = gr.sys_id;;
current.update();
gs.info("Name is2222: " + gr.name);
gs.info("Name is111: " + current.account);
if(gr.contact==''){
var update = new GlideRecord('sys_user')
update.addQuery('email',email.from)
update.query();
if(update.next())
{
gr.contact=update.sys_id;
gr.update();
}
else
{
var create = new GlideRecord('sys_user')
create.initialize();
create.email=email.from;
create.name=email.from;
create.user_name=email.from;
create.insert();
gr.contact=create.sys_id;
gr.update();
}
}
}
//current.u_insp_email = domain;
})(current, event, email, logger, classifier);
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 02:06 AM - edited ‎11-23-2022 02:34 AM
tried with this also but it is not getting saved in the accounts
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 02:12 AM
hello,
I can see the i beside the field which means there is a record. i beleive as you are not setting user id from the script and user id being the display field hence you see the field empty but the value is actually there click on the i icon.
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 02:16 AM
as your suggestion the user id is created
but I need to set the user id from the script automatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 02:27 AM
Hello,
For the time being you can set the email id itself in the userid as that is the unique value
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
current.u_insp_email = email.from;
var domain = email.from.split('@')[1];
gs.info("Name is: " + domain);
var gr = new GlideRecord('customer_account');
gr.addEncodedQuery('u_emailidCONTAINS' + domain);
gr.query();
if (gr.next()) {
current.account = gr.sys_id;;
current.update();
gs.info("Name is2222: " + gr.name);
gs.info("Name is111: " + current.account);
if(gr.contact==''){
var create = new GlideRecord('sys_user')
create.initialize();
create.insert();
create.email=email.from;
create.name=email.from;
create.user_name=email.from;
gr.contact=create.sys_id;
gr.update();
}
}
//current.u_insp_email = domain;
})(current, event, email, logger, classifier);
Please mark my answer as correct based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 02:34 AM - edited ‎11-24-2022 12:16 AM
not setting automatically in the contact