Duplicate RITM created in Service Catalog

dbatch01
Kilo Explorer

We have about 70 items in our Service Catalog.   We have one item which is creating two items in the shopping cart every time it's checked out.   This, in-turn generates 2 approvals and two RITMs.  

One of them has all the information that was submitted, the second is missing variables on the RITM form.   This happens on every submission of this one item, but nowhere else.   For the life of me I cannot find what the issue may be.

23 REPLIES 23

Hi,


Thanks for the assistance.   I've checked the business rules and it's definitely not that.



It's actually far more entertaining.....and much more bizarre.



While doing more testing, I found that the population of a field is causing the additional item in the cart...



I'll try to explain.



tablet.jpg


The Carrier field is populated via a client script, based on a table.   Once information is added to the Carrier field, an onChange script runs to populate the Device table.   When I populate the Carrier field, then edit the item, then try it again...voila, there is an item in the cart, and I have not checked anything out yet, nor added it to the cart.   There is nothing I can see in the scripting that could generate an additional record (and is exactly the same script we are using on another form, which does not have this issue).



The onChange script is:



var country = g_form.getValue("country");
var carrier = g_form.getValue("carrier");
var user = g_form.getValue("requested_for");



var ga = new GlideAjax("getChoiceValue");
ga.addParam("sysparm_name", "getTabletDeviceModel");
ga.addParam('sysparm_country',country);
ga.addParam('sysparm_carrier',carrier);
ga.addParam('sysparm_user',user);
ga.getXML(ajaxResponse);

}


function ajaxResponse(serverResponse) {
var choices = serverResponse.responseXML.getElementsByTagName("choices");
g_form.clearOptions('device');
g_form.addOption('device', '', getMessage('-- None --'),0);



for(var i = 0; i < choices.length; i++) {
    var label = choices[i].getAttribute("name");
    //var value = choices[i].getAttribute("value");
    //alert("New Device Value: " + label + ", " + value);
 
  //g_form.addOption('device', value, label);
  g_form.addOption('device', label);
}

g_form.setReadOnly('device', false);



And the getChoiceValue script has:



var country = this.getParameter('sysparm_country');
  var carrier = this.getParameter('sysparm_carrier');
  var user = this.getParameter('sysparm_user');
  var exec = '';
  var name = '';
  var grUser = new GlideRecord('sys_user');
  grUser.addQuery('sys_id',user);
  grUser.query();
  if (grUser.next()){
    exec = grUser.u_edir.u_isexec;
  }
 


  var grDevice= new GlideRecord('device_table');
  grDevice.addQuery('country', country);
  grDevice.addQuery('carrier',carrier);
  grDevice.addQuery('u_type','tablet');
  grDevice.query();
 
  //var count=0;
 
  while (grDevice.next()) {
    var msg = '';
    if(grDevice.u_make=='Apple'){
      if (exec=='TRUE'){
        msg = this.newItem("choices");        
        name = grDevice.device + " - [$" + grDevice.u_price + "]";        
        msg.setAttribute("name", name);
        msg.setAttribute("value", grDevice.device);
      }
      if(exec!='TRUE'){
        if(grDevice.u_for_executives!=true){
          msg = this.newItem("choices");          
          name = grDevice.device + " - [$" + grDevice.u_price + "]";          
          msg.setAttribute("name", name);
          msg.setAttribute("value", grDevice.device);
        }
      }
    }else{
      msg = this.newItem("choices");      
      name = grDevice.device + " - [$" + grDevice.u_price + "]";      
      msg.setAttribute("name", name);
      msg.setAttribute("value", grDevice.device);
    }
  }
},


So at the moment, we suspect that the issue is in the field it's self.   There is no code, rules or workflow running that causes the problem.   As soon as we rename the field, all seems to be ok for some unknown reason.   Very strange...very, very strange indeed.


I can suggest that you search through the system for "carrier".


goranlundqvist 's Where did I write that piece of code? saved me a few times already.



Also, maybe you can activate field watcher on the field and see what happens in the console when you change it.


harel


Sadly, I'm actually still on Fuji (we are in planning to update to Istanbul) and don't have access to the Code Search.   That being said, I've already searched through all the code and there is nothing that would create a shopping cart entry without submitting the item.   One thing to note is that field name is used in other catalog items, which don't have the same problem.  



Still looking through things to find the root cause....