Can we set conditions on catalog client scripts?

gnunez
Kilo Guru

Hello all,

I am creating a catalog item and the first question is "Are you opening this request on behalf of someone else?" if they select No then I want the catalog client scripts to trigger because it'll prepopulate the other fields with first name, last name, employee id, etc. If they select Yes I do not want the client scripts to trigger because the user should fill out those fields manually.

Are conditions on catalog client scripts possible or would anyone recommend another best practice for this scenario?

Thanks in advance,

Grace

1 ACCEPTED SOLUTION

Can you try this if your issue not solved yet.
I assume OPENED_BY field is there on catalog item and it already have the current user's record

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	var request_behalf = g_form.getValue('request_behalf');
	if(request_behalf == 'request_no'){
		g_form.setValue('first_name', g_user.firstName);
		g_form.setValue('last_name', g_user.lastName);
		var emp = g_form.getReference('opened_by', setEmpID);
	}
	else
		return;
}
function setEmpID(emp){
	g_form.setValue('empid', emp.employee_number);
}

View solution in original post

17 REPLIES 17

purbalipc
Tera Expert

if (<reply>=="No")

   return false;

 

That should work.

Is this in addition to what Kumar suggested above? 

Thanks

That is correct, in addition to what is suggested above.