How can I print out the message in the system log and in the requested item?

John242
Giga Contributor

Hello,

I am new to ServiceNow, and I am trying to solve this task. So far, everything is going well the only point I cannot implement.


The workflow assigned to this catalogue item should print out a log in the system logs to say "User <name of the user> has ordered more  <phone or tablet> for server <server name>". It should be written also in the Work Notes field of the Requested Item. Set the state of the RITM to Closed complete after writing the messages in the previous step.

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi John,

Glad to connect and your issue was Resolved. Please mark my answer as correct and close this thread.

Same as below thread:

https://community.servicenow.com/community?id=community_question&sys_id=d9d6c24d1bf40d94d01143f6fe4bcbeb

 

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

12 REPLIES 12

Prasad Dhumal
Mega Sage
Mega Sage

Hello John

To add work notes via script, you can use below syntax:(you can use run script in workflow to add this)

current.work_notes = "User <name of the user> has ordered more  <phone or tablet> for server <server name>"

To add system log, you can refer below syntax:

gs.log('User <name of the user> has ordered more  <phone or tablet> for server <server name>');

 

for <name of the user>, <phone or tablet>, <server name> use backend names of fields to add.

you can configure it by concating your string like below: 

current.work_notes = 'User'+userBackendFieldName+' has ordered more'+ 'phoneortabletBackendFieldName+' for server'+BackendFieldNameservername

Hello Prasad,

 

Thank you for your suggestion. I have a question though how can I receive their backend names? I mean I know the variable name usually is in design form. Is it the same for the backend part?

You can track down the backend names of variables by following ways:

1 way)

Go to maintain items > open catalog item > variables

find_real_file.png

 

way 2)

Right Click on variable on form > Configure Variable

find_real_file.png

 

find_real_file.png

 

The script I provided above is to access FIELDS. 

In your case you have variables so please use below syntax to access variable in workflow:

 

current.variables.variable_name

 

Your script will look like this:

 

 

current.work_notes = 'User'+ current.variables.variable_name +' has ordered more'+ 'current.variables.variable_name+' for server'+current.variables.variable_name

Okay, so first I try to test the workflow with the new string which I created for the requested item, and it does not work yet.

I am attaching some screenshots for a better grasp of my issue.

workflowfind_real_file.png

catalogue item

find_real_file.png

 

request find_real_file.png

find_real_file.png

requested item

find_real_file.png