Friday, September 21, 2018

Retain the Lead Status of an Entity Record when the Sales Order created has Zero amount

A Lead record is automatically converted to a Customer record if a Sales Order is created for the Lead record. Customer wants to retain the Lead status if the amount of Sales Order created is zero.

  1. Create a User Event script deployed on the After Submit function of the Sales Order record.
  2. The script sets the status of entity back to Lead-Unqualified.
     
function afterSubmit(type, name)
{
  var amtTotal= nlapiGetFieldValue('total');
   if(amtTotal==0){
      var recId = nlapiGetFieldValue('entity');
      var rec = nlapiLoadRecord('customer',recId);
      rec.setFieldValue('entitystatus', 6); //where 6 is 'Lead-Unqualified'
      var id = nlapiSubmitRecord(rec);
   }
}
 

 

Note: that the Sales Order is still attached to the Lead record.

No comments:

Post a Comment