The CreatorCon Call for Content is officially open! Get started here.

How to combine two onSubmit Catalog Client Scripts for same variable?

Mark Nguyen
Tera Guru

Hello Now Community,

 

Apologies ahead my scripting skills are not the best.

 

I have two onSubmit catalog clients working seperately below however when both are enabled only one will work. My requirement is to display a single error messages "Please use SailPoint Access Request" or "Please use SAP Access Request" based off a yes/no variable.

 

onSubmit Catalog Client Script #1

 

function onSubmit() {
	if(g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'yes') 
		g_form.addErrorMessage('Please use SAP Access Request');
		g_form.submitted = false;
		
		//Abort the submission
		return false;
	}

 

onSubmit Catalog Client Script #2

 

function onSubmit() {
	if(g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'no') 
		g_form.addErrorMessage('Please use SailPoint Access Request');
		g_form.submitted = false;
		
		//Abort the submission
		return false;
	}

How can I combine the two above into one onSubmit Catalog Client script?

 

Thank you,
Mark 

1 ACCEPTED SOLUTION

@Mark Nguyen : I just combined two into a single script.

 

function onSubmit() {
    if (g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'yes') {
        g_form.addErrorMessage('Please use SAP Access Request');
        g_form.submitted = false;
    }

    if (g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'no') {
        g_form.addErrorMessage('Please use SailPoint Access Request');
        g_form.submitted = false;
    }

    //Abort the submission
    if (g_form.submitted == false) {
        return false;
    }
}

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

View solution in original post

4 REPLIES 4

Sainath N
Mega Sage

@Mark Nguyen : As it's a yes/no variable only one error message will be displayed at any time right? As the value should be either yes or no? Is my understanding correct?

Hi @Sainath N yes that is correct only one error message will be displayed at any time. The error message to be displayed is dependant on yes or no selection to variable 'do_you_have_access_to_submit_for_the_emergency_access_through_grc'.

 

If no is selected, I want the error message 'Please use SailPoint Access Request' displayed.

If yes is selected, I want the error message 'Please use SAP Access Request' displayed.

 

Thanks

@Mark Nguyen : I just combined two into a single script.

 

function onSubmit() {
    if (g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'yes') {
        g_form.addErrorMessage('Please use SAP Access Request');
        g_form.submitted = false;
    }

    if (g_form.getValue('do_you_have_access_to_submit_for_the_emergency_access_through_grc') == 'no') {
        g_form.addErrorMessage('Please use SailPoint Access Request');
        g_form.submitted = false;
    }

    //Abort the submission
    if (g_form.submitted == false) {
        return false;
    }
}

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thank you very much @Sainath N this worked! Appreciate it greatly.