How to display alert message/popup with details of variable?

Gemma4
Mega Sage

Hi everyone,

Can anyone help me as I need to display a alert message after a catalog item is submitted for the user to confirm the variable "request_name" is correct. The script should give the user the opportunity to confirm the details are correct or cancel the request. Is this possible?

 

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Gemma4 ,

 

You can write an onSubmit client script where u can have this below script for putting up a confirmation message before submitting it

 

var answer = confirm('Are the variables correct?')//update message as per your need

 

If(!answer){

return false;

}

 

Please mark my answer helpful & accepted if it helps u resolve your query.

 

Thanks,

Danish

I tried the script you provided and it gives an error. see attached. 

I tried a catalog client script and it displayed the pop up message but did not include the variable results for request_name. See attached. any other ideas?

 

function onSubmit() {
g_form.getReference('request_name', doPopup);
// g_form.getReference('requested_for', doPopup);
}

function doPopup(reqFor) {
var popup = confirm('Are you sure the request name field is correct ' + reqFor.getValue('name') + '?');
// alert('popup val is: ' + popup);
// if (!popup) {
// return false;
// } else {
// return false;
// }
}

Hi @Gemma4 ,

 

Please see the below screenshots

DanishBhairag2_0-1695669638129.png

 

DanishBhairag2_1-1695669686133.png

 

function onSubmit() {
   //Type appropriate comment here, and begin script below.
   var value = g_form.getValue('first_name'); // enter your variable name which u want to print on alert

   var answer = confirm('Are the entered variables correct First Name: '+ value);

   if(!answer){ // if cancel is pressed it will not allow the catalog item to submit
	return false;
   }
   
}

 

 

Please mark my answer helpful & accepted if it helps you resolve your query.

 

Thanks,

Danish