Business rule or Client script for updating a field value in a reference table

Nitin Baijal
Tera Expert

Hi Experts,

I have a requirement. I have a catalog item to perform the task below -

Update the "Owner" field in a reference table with a new Owner.

example , if user1 is the owner of a mailbox, we can use this form to update its owner to user2.

I am able to gather all the information on the catalog item - mailbox name, current owner, new owner and then create a task through workflow steps to change current owner to new owner

 

The last part of this requirement is - 

"Create a business rule so that after the task is created, the new user is automatically made the owner of the mailbox, then close the task."

I believe an after business rule will work best for it where I just update the owner field with the new value.

Can anyone please help me with configuration and scripting part of it?

11 REPLIES 11

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Yes Business rule looks better option here since you want to update once task is created then task should be closed so you can write sample After Business rule on SC_TASK table but add condition should as short description so that BR should run only for this SCTASK, code can be like below

var ee = new GlideRecord('tablename');
ee.addQuery('owner' , current.variables.old_owner);
ee.query();
if(ee.next())
{
ee.owner = current.variables.new_owner;
}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab

I tried following what you said but i think i am missing something.

I did not find Short description but i did find subject title in filters.

NitinBaijal_1-1671641828858.png

 

 

NitinBaijal_2-1671641872270.png

how do i check if the business rule actually even ran? i checked system Diagnostics>Debug business rule but i dont see anything there 😞

 

I am getting this error when this script is run - 

Evaluator: com.glide.script.RhinoEcmaError: Cannot read property "variables" from null
   script : Line(5) column(0)
      2: 
      3: 	// Add your code here
      4: var ee = new GlideRecord('u_inigo_shared_mailbox');
==>   5: ee.addQuery('owner',current.variables.current_owner);
      6: ee.query();
      7: if(ee.next())
      8: {

I think it is just a small thing that we are missing, i am unable to put my finger on it.

Try below ?

current.request_item.variables.current_owner

Please hit like and mark my response as correct if that helps
Regards,
Musab