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.
- Create a User Event script deployed on the After Submit function of the Sales Order record.
- 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);
}
}
{
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