'requested_for' field on catalog task not working for client script.

DevtoSME
Giga Guru

I'm having issues with the 'request_for' field on the catalog task form not working in my client script.

this client script has been used on the incident/RITM/change and interction form.

 i tied to use 'sc_task.request_item.requested_for' and its still not working.

 

can anyone guide me on how to get this to work. 

I've attached screen shots

1 ACCEPTED SOLUTION

No worries, let's try this.

Create a Display Business Rule with the following script:

(function executeRule(current, previous /*null when async*/) {

	//Use one of the following 2 options:
	g_scratchpad.grade_of_service = current.request_item.requested_for.u_grade_of_service;

	//OR if you want to invoke your script include, you can do the following
	g_scratchpad.grade_of_service = new UserUtils().getGradesOfService(current.request_item.requested_for.toString());

})(current, previous);

Note that you can use either line of script.

 

Then within your client script:

//Replace the original script from line 7 to 17 with the following
if (g_scratchpad.grade_of_service == 'elite') {
    g_form.showFieldMsg('request_item.requested_for', 'This user is Elite', 'error');
} else {
    g_form.hideFieldMsg('request_item.requested_for');
}

View solution in original post

6 REPLIES 6

No worries, let's try this.

Create a Display Business Rule with the following script:

(function executeRule(current, previous /*null when async*/) {

	//Use one of the following 2 options:
	g_scratchpad.grade_of_service = current.request_item.requested_for.u_grade_of_service;

	//OR if you want to invoke your script include, you can do the following
	g_scratchpad.grade_of_service = new UserUtils().getGradesOfService(current.request_item.requested_for.toString());

})(current, previous);

Note that you can use either line of script.

 

Then within your client script:

//Replace the original script from line 7 to 17 with the following
if (g_scratchpad.grade_of_service == 'elite') {
    g_form.showFieldMsg('request_item.requested_for', 'This user is Elite', 'error');
} else {
    g_form.hideFieldMsg('request_item.requested_for');
}

Jim Coyne
Kilo Patron

Couple things first to help you get help with your questions:

- easier to past the screenshots right into the post so we can see without having to click on it to see it or download it.  I've had to click on it numerous times while trying to respond.

TNT: Screenshots Help, but Code is Better

TNT: And Formatted Code is Even Better

 

Now, you might consider adding the dot-walked "u_grade_of_service" field to the form and add a UI Policy to hide it if it is not "elite".  Code-free solution.

 

If you still want to use a showFieldMessage to, well, show a message, you might want to use "warning" instead of "error" and just use "error" for real errors.