sachin_namjoshi
Mega Patron

You don't need any coding for this requirement.

You can use flow designer flows to update record with these appended values.

 

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/flow-designer/referen...

 

Regards,

Sachin

 

This still doesn't help because the words/lines name, city & country are already there.  I just need to be able to collect the values and paste them after the colon ( : )

Brad Bowman
Mega Patron

If your UI Action is running on the sc_req_item table, use current.variables.variable_name to access those values. As long as Name, City, and Country are all text variables, and assuming description is a long string field it's going to be easiest to wipe the field value and rebuild it with your variable values, so something like this

var name = current.variables.name;
var city = current.variables.city;
var country = current.variables.country;

var desc = 'Provide the following:\n Name: ' + name + '\nCity: ' + city + '\nCountry: ' + country;

Then use desc to update the field on the newly-created change request.  If name or any of these are reference variables, then you'd have to do a GlideRecord to lookup the display value first.

View solution in original post

If i do this, wouldn't the name, city & the country be added again to the description field? remember that those lines/words are already there.

So i pretty much need to pass the values only and position them after the colon ( : ).

This is the problem I am having, the client wants no matter what those words to be there in the description template no matter what i say to them .

 I have not tried this yet but i guess i can give it a try and see if it wipes out what's already there/

I'm assuming we're talking about a single string field that you are populating in a Standard Change Template.  So if you did nothing to this field when you create a change, the incomplete text will be there within the Description field.  If you were to look at the value stored in that field, it would be a single string.  This is why you can't just append 3 values after the colons - there's a few ways to do it, but you end up with a new complete single string in any event that needs to be saved to the description field.  Your change request creation steps are going to include setting the value of the Description field to this new string, so it will replace what's already there - just the same as if you were to populate Assignment group, Service, or any other field that isn't part of the template.  The question is when creating the change request via a UI Action, which will happen first, so what will be the resulting value on the created record - the incomplete template value, or your new complete string?  Give it a try and see.  If the template wins you can try to add to your UI Action script to immediately update this field on the newly-created record, or another option is to populate your complete description string in another field that is unused upon creation, like Test plan or something other than Description, then add an after insert Business Rule that copies Test plan to Description, then clears Test Plan - same end result, and the template stays as it is for changes created outside of this UI Action.