Hwo to use currency type in catalog variable

shaik_irfan
Tera Guru

Hello Everyone,

I wanted to create a variable with type as currency is there any type to display ??

find_real_file.png

3 REPLIES 3

Ujjawal Vishnoi
Mega Sage
Mega Sage

shaik_irfan
Tera Guru

Hello Shaik,



Please go through below link which is similar to your query




How to define variables of type Price in the Service Catalog


//Replace cost with your variable name:



function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }


  //Type appropriate comment here, and begin script below


  var cost = g_form.getValue('cost');//Replace cost with your variable name:


  cost = cost.trim();



  // first character should be dollar sign



  var firstChar = cost.substring(0,1);


  if (firstChar != '$') {


  alert ("Please enter cost in $0.00 format");


  g_form.setValue("cost", oldValue);//Replace cost with your variable name:


  return;


  }



  // characters after the $ sign should be numerics



  var costType = isNaN(cost.substring(1));


  if (costType == true) {


  alert ("Please enter cost in $0.00 format");


  g_form.setValue("cost", oldValue);//Replace cost with your variable name:


  return;


  }



  // entered value should have a decimal point



  var num = cost.substring(1);


  if (num.indexOf('.') == -1) {


  alert ("Please enter cost in $0.00 format");


  g_form.setValue("cost", oldValue);//Replace cost with your variable name:


  return;


  }



  // there must be 2 digits only after the decimal



  var decNum = num.substring(num.indexOf('.')+1, num.length);


  if (decNum.length != 2) {


  alert ("Please enter cost in $0.00 format");


  g_form.setValue("cost", oldValue);//Replace cost with your variable name:


  return;


  }


}




Note: enter value must have '.' decimal value




Cheers
Abdul Azeez
---------------
Note: Hit like, Helpful or Correct depending on the impact of the response