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

So I did another test and harcoded a sysid value into the html form to see is everything got passed and run correctly in the processing script (it did!). 

 

So it appears at this point that I am incorrectly retrieving the customRecordID in the HTML part of the UI page. 

 

<?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 conversion option and click ok to proceed.</h1> 
	<p>This is the customRecordID - ${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>

 

I think I'm doing something wrong in one of the two lines below pretty sure it's line 3 because that value comes out as null when I try to print it

 

line 3

<g:evaluate var="jvar_customRecordID" expression="RP.getWindowProperties().get('customRecordID')" />

 

line 6

<input type="hidden" id="recordsSysID" name="recordsSysID" value="jvar_customRecordID"/> 

 

 

I do not think this is setting the value of jvar_customRecordID. Try removing double quotes

 

<input type="hidden" id="recordsSysID" name="recordsSysID" value="jvar_customRecordID"/> 

alondc
Mega Contributor

When I try to remove the double quote I get this error 

 

Error at line (6) Open quote is expected for attribute "value" associated with an element type "input".

try this

<input type="hidden" name="recordsSysID" value=${jvar_customRecordID}/>

alondc
Mega Contributor

It's still giving us this error 

 

<input type="hidden" id="recordsSysID" name="recordsSysID" value=${jvar_customRecordID}/> 

 

produces the same error message 

 

Error at line (6) Open quote is expected for attribute "value" associated with an element type "input".