Returning object from script include

k_jayanth
Tera Contributor

I just have a small problem in retrieving the returned value, i'm calling a business rule on change request form to retrieve the 'assigned_to' of the two change tasks. I'm able to fetch the value of the assigned_to but unable to return it. i have a screenshot of the code below.

Business Rule:

find_real_file.png

I'm getting undefined when i display the answer.

Script Include:

find_real_file.png

When i use logs it displays the obj values as required, so there is some problem in encoding or decoding the values.

And i need one more help, when the values are sent back it should be added to the eventQueue as parameters as you can see in the business rule.

So when the event is fired a notification will run.

When to send:

find_real_file.png

Who will receive:

find_real_file.png

i have to send it to three users, opened by and the two assigned_to of the tasks, so I have checked the two parameters as receivers, so is this enough to send notification email to all three or is there anything else i need to do.

This is my first time working on notifications so i don't have much idea how this works, please point out if i need to make any changes.

Many Thanks!!

- Jayanth

8 REPLIES 8

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Do you really need to get assigned_to in an object?


Why not just returning the sys_id of the assigned_to (reference field to sys_user) and then get that directly from sys_user?


Hi Sergiu, thank you for responding,


I have to return two sys_id's, so i preferred using obj, is there any other way?


To me it looks you can't have both in the same time, right? As you can't have 2 different short descriptions for same record. So you actually return only one sys_id at any point in time.


The if statement is just to differentiate the tasks, but there are already two tasks and i need the sys_id of both tasks assigned_to.   Only reason for using the if statement is so that i can store the sys_id of implement task assigned_to in obj.one and post implement task assigned_to value in obj.two. The while loop will run two times, first it'll fetch the imp.. task assigned_to and next the post imp.. task assigned_to.