Unexpected value in g_form.getDisplayValue client script onLoad

jamess_
Tera Contributor

onLoad client script on Incident table. Functionality was intended to be: Check status and display message accordingly. Was not working as expected, so I added messages 1 and 2.

function onLoad() {
   //Type appropriate comment here, and begin script below
if (g_form.getDisplayValue('u_contractor_incident_no') > 0) {

	if (g_form.getDisplayValue('u_contractor_status') == '2') {
	g_form.addErrorMessage('Contractor Incident Complete. No further updates will be received.');
	}
	else if (g_form.getDisplayValue('u_contractor_status') == '3') {
		g_form.addErrorMessage('Contractor Incident Closed. No further updates will be received.');
	}
	else if (g_form.getDisplayValue('u_contractor_status') == '4') {
		g_form.addErrorMessage('Contractor Incident Cancelled. No further updates will be received.');
	}
	else if (g_form.getDisplayValue('u_contractor_status') == '10') {
		g_form.addErrorMessage('Contractor Incident Returned. No further updates will be received.');
	}
	else{}
	g_form.addErrorMessage('1. Contractor Status is ' + g_form.getDisplayValue('u_contractor_status'));
}
else {
	g_form.addErrorMessage('2. Contractor Incident number is ' + g_form.getDisplayValue('u_contractor_incident_no'));
}
}

 

Message #2 is now displaying, but the message reads "2. Contractor Incident number is INC000999999", and is the currently displayed Incident number, rather than the field specified. Am I somehow making a reference to the 'number' field, and not realizing it? I verified that the 'u_contractor_incident_no' is not the same value as the local Incident number.

Any assistance greatly appreciated.

1 ACCEPTED SOLUTION

This is strange. I'm out of ideas, but maybe try simply using g_form.getValue('u_contractor_incident_no');

View solution in original post

19 REPLIES 19

This is strange. I'm out of ideas, but maybe try simply using g_form.getValue('u_contractor_incident_no');

I'd swear I'd tried that first, but that's corrected the issue. A couple "thanks" in store, I think:

function onLoad() {
   //Type appropriate comment here, and begin script below
var no = g_form.getValue('u_contractor_incident_no').toString();
var sts = g_form.getValue('u_contractor_status').toString();

if (no.length > 0) {

	if (sts == '2') {
	g_form.addErrorMessage('Contractor Incident Complete. No further updates will be received.');
	}
	else if (sts == '3') {
		g_form.addErrorMessage('Contractor Incident Closed. No further updates will be received.');
	}
	else if (sts == '4') {
		g_form.addErrorMessage('Contractor Incident Cancelled. No further updates will be received.');
	}
	else if (sts == '10') {
		g_form.addErrorMessage('Contractor Incident Returned. No further updates will be received.');
	}
	else {
	g_form.addErrorMessage('1. Contractor Status is ' + sts);
	g_form.addErrorMessage('2. Contractor Incident number is ' + no);
	}
}
else {
	g_form.addErrorMessage('3. Contractor Status is ' + sts);
	g_form.addErrorMessage('4. Contractor Incident number is ' + no);
}
}

jamess_
Tera Contributor

Although I'm admittedly still confused where the Incident Number value was coming from.

Did you look at the value in the field? Maybe nothing is wrong with script, just the field contains the incident number and not the 4 digit number.

Kenneth Zabrisk
Tera Guru
Same issue, 6.5 years later.

//Type appropriate comment here, and begin script below
   var vstage = g_form.getDisplayValue('stage');
   var vstate = g_form.getDisplayValue('state');
   g_form.addInfoMessage('hello');
    g_form.addInfoMessage(vstage);


The output messages:

KennethZabrisk_0-1731011835159.png

but from the XML

<stage>request_rejected</stage>
Displayed as:

KennethZabrisk_2-1731011987210.png