- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2023 10:31 AM - edited ‎07-18-2023 10:32 AM
I am working on an UI action button, In which I need to use variables from client side function in next server side function . But I am getting undefined values in the description
Below is the code of UI action
///////////////////////////////////////////////////////////////////////////////////////////////////
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2023 08:27 AM
Hi @Reddymahesh ,
If you want to add to Workspace there is a Workspace tab where you can choose Workspace Form Button to make the UI action appear on the line of UI actions, or Workspace Form Menu to make it appears as a list item in the menu list.
If the code for the UI action I provided earlier works for the creation of RITM and can populate description successfully could you please mark the answer as correct? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2023 10:42 AM
Try an intermediate variable perhaps? I'm thinking it's not actually storing the value in the variable after the prompt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2023 05:31 AM
It's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2023 08:10 AM
Do both alerts produce the same result? (both of them have the correct values in the variables?)
You may need to update your glide, too. It looks like you're trying to insert directly into the RITM table...I would recommend inserting into task (task)...also, I would take the setRedirectURL out of the function...and is there a reason you are only calling the update function if the window is undefined (does it work without that if statement) ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2023 09:39 AM
Hi @Reddymahesh ,
You cannot pass the value from client to server in that way because this "gsftSubmit(null, g_form.getFormElement(), "user_change_name");" will call the UI action again to run on server side and it will also declare again your FirstName and LastName variable, that is why they are undefined.
You can prompt user from Client side, then call GlideAjax to create new record with the user input, something like this:
function input() {
var first = prompt("Please enter First name");
var last = prompt("Please enter Last name");
var fullName = first + ' ' + last;
if (fullName != '') {
var ga = new GlideAjax('testScriptInclude');
ga.addParam('sysparm_name', 'testFunc');
ga.addParam('sysparm_fullname', fullName);
ga.getXML(processResponse);
} else return false;
}
function processResponse(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
action.setRedirectURL(current);
}
In Script include:
testFunc: function() {
var gr = new GlideRecord('sc_req_item');
gr.initialize();
gr.assignment_group = '4a1d990547056510d2c3b604836d432e'; // ServiceNow admin team
gr.description = 'Change the name to: ' + this.getParameter('sysparm_fullname');
gr.insert();
},