Requested For - Default to empty

JLeong
Mega Sage

How can I empty the "Requested For" by default in Helsinki? This was working in Geneva until I changed the Service Catalog Properties to Use the sc_layout driven cart macros

The onload client script doesn't work anymore.

function onLoad() {

g_form.clearValue('requested_for');

}

Thanks.

Jocelyn

1 ACCEPTED SOLUTION

Here's what I found... it's set by the UI macro sc_cart_view_requested_for.



This is added to the cart layout record: Shopping Cart (target: Cart Preview Screen (two step)). Since you cannot modify the original UI macro, you can copy it, update the copy so it does not set the variable (see lines 8 and 9 in the macro), then replace the usage of the macro in the cart layout's related list with your new one.


View solution in original post

12 REPLIES 12

tanumoy
Tera Guru

Did you try to remove the default value?


Chuck Tomasi
Tera Patron

Can you help me understand what the use case is for having the field empty?


Chuck Tomasi
Tera Patron

Try setting the default value... Go to the request form, right click and select Configure Dictionary


find_real_file.png



In the Default Value section, check the default value.



find_real_file.png


Set it accordingly. Above is an example of NO default value.


Hi Chuck,



I need to default the "Requested For" to blank because users keep forgetting to change it and they ended up requesting for themselves.


However, I have few Service Catalog items that can't be ordered on behalf of others. So I still need the default.



Below is the entire onLoad script:



function onLoad() {


  var user = g_form.getValue('requested_for');


  var ga = new GlideAjax('VerifyCart');


  ga.addParam('sysparm_name','verifyCart');


  ga.addParam('user',user);


  ga.getXML(CartParse);



  function CartParse(response) {


  var answer = response.responseXML.documentElement.getAttribute("answer");


  if(answer != ''){


  var text = 'If you would like to request for someone other than yourself, please remove the following service(s) from your cart: ' + answer;


  document.getElementById("sys_display.sc_cart.requested_for").disabled = true;


  document.getElementById("lookup.sc_cart.requested_for").style.display = "none";


  g_form.showFieldMsg('requested_for',text,'info');


  } else{


  g_form.clearValue('requested_for');


  g_form.clearValue('requestor_location');


  }


  }


}