How to call email script from business rule event

lucky24
Tera Contributor

Hi,

I have to send a notification to one specific group when the seating type changes of the user from SC tasks.And I want to capture task details in notification but I have configured notification in the sys_user table and I am triggering this from the business rule event.

But I want to capture task details for that I am trying to call the email script but I am getting fail.

Business rule

Business rule--

gs.log("Test1 " + " Outside");
     var group = gs.getProperty("it_group");
	var seating = new GlideRecord("sc_task");
	seating.addQuery("requested_for",current.sys_id);
	seating.query();
	if(seating.next()){

		gs.eventQueue("it_notification",seating,group,seating.sys_id);
		gs.log("Test2 " + " Inside");
		gs.log("Test3 " + group);
	}

Email script

Email script-

gs.log("Test emails " + event.parm2);

    var task = new GlideRecord("sc_task");
    task.addQuery("sys_id", event.parm2);
	task.query();
	while(task.next()){
		gs.log("Test emails inside " + event.parm2);
	}

 

 Please help me and guide me here

2 REPLIES 2

dgarad
Giga Sage

Hi @lucky24 

 try the below code in the email script.

var task = new GlideRecord("sc_task");
    task.addQuery("sys_id", current.sys_id);
	task.query();
	while(task.next()){
		gs.log("Test emails inside " + event.parm2);
	}

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Mark Manders
Mega Patron

Why are you triggering it on the user table? Why not on the sc_task table? Looking at your query: that's the seating. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark