Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Dylan Mann1
Giga Guru

Is this a reference field to the Incident Table? I would look into how that field is populated.

 

You're expecting the output to be an Incident Number, but not the Incident number of the current record, correct?

 

Dylan

It is a custom field in the Incident Table. In this case, it is a 4-digit number. Within the Incident record, I have a field that tracks a 3rd party's Incident number. I'm expecting that 3rd Party's incident number, not my own.

Michael Fry1
Kilo Patron

This line - if (g_form.getDisplayValue('u_contractor_incident_no') > 0) { - is evaluating to false. Is u_contractor_incident_no an integer field?

It should be, yes, although I've also tested w/ '' just in case.

My issue wasn't so much with the logic, but rather the troubleshooting steps I took aren't even functioning the way I expected so I could work on the logic.