Inbound email Guest user

Rushi2
Tera Expert

Hi All , 

 

I am trying to create incident through inbound email action , If user is not present it has to populate guest user which is hard coding in script. but it is not working.  Please see script below. let me know what is the issue here 

 

var callerID =  gs.createUser(email.from);

            //var callerID = queryTable("sys_user","email",email.user);

            if(callerID != ''){

                        current.caller_id = callerID;

            }

            else {

                        current.caller_id = '327f735adb7d17403ffa36be3b96194a';

            }

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Try the below code.

var newUser = new GlideRecord('sys_user');
newUser.addQuery('email', email.from); 
newUser.query();
if(newUser.next()) {
  current.caller_id = gs.getUserID();
} else {
  current.caller_id='327f735adb7d17403ffa36be3b96194a'; //ensure the sys_id of user is correct here.
}
current.insert();

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

2 REPLIES 2

asifnoor
Kilo Patron

Try the below code.

var newUser = new GlideRecord('sys_user');
newUser.addQuery('email', email.from); 
newUser.query();
if(newUser.next()) {
  current.caller_id = gs.getUserID();
} else {
  current.caller_id='327f735adb7d17403ffa36be3b96194a'; //ensure the sys_id of user is correct here.
}
current.insert();

Mark the comment as a correct answer and also helpful once worked.

thank you so much, it's working as expected.