can't access the sysID of the record where ui action was trigger in the following ui page processing script

alondc
Mega Contributor

Hi Community, 

 

I'm at my wit's end here. I built a ui action and a ui page in a custom application. The UI action is successfully calling the UI page and the client script is processing and displaying the alert I configured. I have not been able to successfully pass the sysID of the record from which the UI action was initially launched into the processing script to trigger all of the server side changes that I would like to make. 

I feel like i've looked everywhere and tried everything at this point and am totally stumped, some links to content I looked at are below. 

 

And here is the code for both elements 

 

UI Action

client box is checked and onlick is set to conversionType() ) 

function conversionType()
{
		var custom_record_id = g_form.getUniqueValue().value;
		var gdw = new GlideDialogWindow("x_custom_application_table");	
		gdw.setTitle("Select Option");
 		gdw.setSize(750,300);
		gdw.setPreference("CustomRecordID", custom_record_id);
		gdw.render();
}

 

UI Page 

HTML

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_customRecordID" expression="RP.getWindowProperties().get('customRecordID')" />
<g:ui_form id="phased"><h1>Select the correct gate conversion option and click ok to proceed.</h1> 
	<p>${jvar_customRecordID} - This value is always null</p> 
<input type="hidden" id="recordsSysID" name="recordsSysID" value="jvar_customRecordID"/> 
<input type="radio" id="1" name="phased" value="true"> A phase of this project has been completed </input><br/>
<input type="radio" id="2" name="phased" value="false"> Entire Project Has Been Completed </input><br/><br/>
<button type="submit" onclick="validateForm();"> Continue </button>
</g:ui_form>
</j:jelly>

 

Client Script

function validateForm() {
	var id = g_form.getUniqueValue(); // this works and returns the sysID of the originating record. 
	GlideDialogWindow.get().destroy();//Close the dialog window
	alert(" Client Script triggered! ID of parent record is " + id ); // this works but I can't figure out how to send this value to the processing script
}

 

 

Processing Script 

gs.info('DEBUG >> Comm-test this works');
var gr = new GlideRecord('x_custom_application_table');
gr.info('Glide opened this also works');
gr.get(recordsSysID); // can't find a way to pull the unique id from the client script so trying and failing to pull it from the html
gr.info('Gate number:' + gateSysID); //This always fails to retrieve any value

 

 

 

 

19 REPLIES 19

alondc
Mega Contributor

@Yogi - tried that code and still getting the same results (no sysid displayed in popup and only 1 instead of 3 application logs)

 

Yogi3
Kilo Guru

Does the record on which you have UI action has sys_id? I mean is it only insert? Test by having alert on UI action code to see that it is actually fetching sys_id

alondc
Mega Contributor

Looks like you were right about the UI action issue. When I added the input from both of you I removed the .value and then didn't realize I added it back. I tried the code below with and without the .value, it didn't work with it but the version I pasted below does produce the sysid in the UI action alert I created.

 

 I removed the ".value" from line 3, and added line 4 with an alert to the UI action and got this alert showing the sysID

 

 

function conversionType()
{
 var custom_record_id = g_form.getUniqueValue();
 alert(" Alert triggered from UI action! ID of record is " + custom_record_id );
 var gdw = new GlideDialogWindow("x_custom_application_table"); 
 gdw.setTitle("Select Option");
 gdw.setSize(750,300);
 gdw.setPreference("customRecordID", g_form.getValue('custom_record_id'));
 gdw.render();
}

find_real_file.png

 

The form is still not reading the sys_id correctly though

find_real_file.png

 

In terms of the processing script gr.sys_id is now somehow producing a sys_id... but not the correct one. 

gs.info('DEBUG >> Comm-test this works');
var gr = new GlideRecord('x_custom_application_table');
gs.info('Glide opened this also works');
gr.get(recordsSysID); // can't find a way to pull the unique id from the client script so trying and failing to pull it from the html
gs.info('Record number from form:' + recordsSysID); //This still fails to retrieve any value
gs.info('Record number from gr:' + gr.sys_id); //This is now retrieving a record from the custom app table, but it's not the correct record from which the UI action was triggered. 

 

 

 

Ok use below code then

 

function conversionType()
{
var custom_record_id = g_form.getUniqueValue();
alert(" Alert triggered from UI action! ID of record is " + custom_record_id );
var gdw = new GlideDialogWindow("x_custom_application_table");
gdw.setTitle("Select Option");
gdw.setSize(750,300);
gdw.setPreference("CustomRecordID", custom_record_id);
gdw.render();
}

alondc
Mega Contributor

I tried this code as well replacing

gdw.setPreference("customRecordID", g_form.getValue('custom_record_id'));

with 

 gdw.setPreference("CustomRecordID", custom_record_id);

and am still seeing the same functionality issues