Prevent Catalog Item from Being Submitted If

TStark
Kilo Sage

Is there a way to prevent a catalog item form (portal) from being submitted if a certain choice value is selected in a variable select box? 

Thanks,
AJ

1 ACCEPTED SOLUTION

It depends on the values for the choices.

If you can go to the form, right click the Banks field and select 'Configure choices' you will see the Values for each of the choices.

Lets say that the value for Chase is: chase

and the value for TD Bank is: td_bank

function onSubmit() {
   if(g_form.getValue('u_banks') == 'chase' || g_form.getValue('u_banks') == 'td_bank'){ //change u_banks with the name of your field
      g_form.addErrorMessage('Request was not created'); //change with your message

      //Make sure dirty form still works
      g_form.submitted = false;

      //Abort the submission
      return false;
   }
}

 

Replace the 'u_banks', 'chase', td_bank' with their actual names.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

View solution in original post

5 REPLIES 5

Dan H
Tera Guru

Yes, you can use an OnSubmit Client script.

In the client script, check if the value = the not allowed variable.

Then abort the action.

Example:

function onSubmit() {
   if(g_form.getValue('priority') == 1){
      alert('Record submission aborted.');

      //Make sure dirty form still works
      g_form.submitted = false;

      //Abort the submission
      return false;
   }
}

 

 

Alternatively, you can stop the submission via the Server side, with a Business rule.

Before insert/update business rule. Running on the sc_req_item table and has the condition that request item == the item your referring to.

if(current.priority == 1){
   gs.addInfoMessage('Record submission aborted.');
   current.setAbortAction(true);
}

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Thanks Dan. For the OnSubmit script if the select box field name is 'Banks' and the two choice values that make the form unsubmittable are 'Chase' and 'TD Bank' how would that look on the script?

Thanks,
AJ

It depends on the values for the choices.

If you can go to the form, right click the Banks field and select 'Configure choices' you will see the Values for each of the choices.

Lets say that the value for Chase is: chase

and the value for TD Bank is: td_bank

function onSubmit() {
   if(g_form.getValue('u_banks') == 'chase' || g_form.getValue('u_banks') == 'td_bank'){ //change u_banks with the name of your field
      g_form.addErrorMessage('Request was not created'); //change with your message

      //Make sure dirty form still works
      g_form.submitted = false;

      //Abort the submission
      return false;
   }
}

 

Replace the 'u_banks', 'chase', td_bank' with their actual names.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Perfecto! Thanks Dan.