Passing value from Catalog Item variable to a specific table field

pablopaciullo
Kilo Contributor

Hello team!

I needo to insert a value (string) from a catalog Item variable to a specific field on the table sc_req_item:

target table: sc_req_item

target field: u_oficina_afectada

source variable name: Oficina_afectada

Variable Type: reference

Refers to: cmn_building.

find_real_file.png

Should it go as a calculated field? Is it a script running as part of the workflow??

Can you please indicate me the exact steps should I follow to make it work?

Thank you!!!

Regards,

Pablo

1 ACCEPTED SOLUTION

Jeff Schodde
ServiceNow Employee
ServiceNow Employee

Pablo,


You could achieve this with one of two methods:


  1. A 'before' business rule on sc_req_item. Note: you should consider adding a condition for the script to execute based on the specific catalog item(s) your variables are associated with. Basically, you don't want the business rule script to execute on every sc_req_item record because not all of them will have the same variables.
  2. A Run Script activity in whatever workflow is associated with that catalog item.


The fundamental components for the script would look similar to this:



current.u_oficina_afectada = current.variables.Oficina_afectada;



I hope this helps.



Cheers,


Jeff


View solution in original post

7 REPLIES 7

Jeff Schodde
ServiceNow Employee
ServiceNow Employee

Pablo,


You could achieve this with one of two methods:


  1. A 'before' business rule on sc_req_item. Note: you should consider adding a condition for the script to execute based on the specific catalog item(s) your variables are associated with. Basically, you don't want the business rule script to execute on every sc_req_item record because not all of them will have the same variables.
  2. A Run Script activity in whatever workflow is associated with that catalog item.


The fundamental components for the script would look similar to this:



current.u_oficina_afectada = current.variables.Oficina_afectada;



I hope this helps.



Cheers,


Jeff


Thanks Jeff!! That worked!!!


I just have to resolve how to bring a readable string cause now I ´m having a set of characters there. Guess that is a kind of field type configuration.



Regards,


Pablo


I'm glad it worked out for you!


Jeff


Jeff, it shows the data like this:



find_real_file.png



What should be wrong??