Hi Guys,
Good Morning!
We're encountering an error when creating leads from the web store: "An error occurred during registration: The author internal id or email must match an employee."
This happens when our script, which sets certain values in the lead record, runs during lead creation from the web store.
When a lead is created from the web store, we run a script that sets specific values in the lead record.
We need to set a value for the sales team. If we don't set this value, the script displays an error prompting us to enter a sales team value. When we do set the sales team value, it sets successfully but still shows an error on the registration page. Setting the sales team value is mandatory for us.
Here is the code you can go through it -
else if(subsidiary == 47) {
log.debug('In subsidiary 47 condition-----62');
var objRec = record.load({
type: recordType,
id: rec.id
});
log.debug('objRec-66',objRec);
formId = objRec.getValue({
fieldId: 'customform'
});
log.debug('formId-71', formId);
objRec.setValue({
fieldId: 'customform',
value: '344',
ignoreFieldChange: true
});
formId = objRec.getValue({
fieldId: 'customform'
});
log.debug('updated formId-80', formId);
if(formId == '344')
{
var numLines = objRec.getLineCount({
sublistId: 'salesteam'
});
log.debug('numLines-87',numLines);
if(numLines > 0) {
for(var i = 0; i < numLines; i++) {
objRec.removeLine({
sublistId: 'salesteam',
line: i,
ignoreRecalc: true
});
}
}
objRec.setSublistValue({
sublistId: 'salesteam',
fieldId: 'employee',
line: 0,
value: 7233938
});
objRec.setSublistValue({
sublistId: 'salesteam',
fieldId: 'salesrole',
line: 0,
value: 20
});
objRec.setSublistValue({
sublistId: 'salesteam',
fieldId: 'isprimary',
line: 0,
value: true
});
objRec.setSublistValue({
sublistId: 'salesteam',
fieldId: 'contribution',
line: 0,
value: 100.0
});
}
var updatedRecId = objRec.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
log.debug('Record saved after updating customform-87', updatedRecId);
if((recordType === 'lead' || recordType === 'Customer') && formId === '344') {
var objRecord = record.load({
type: recordType,
id: rec.id
});
log.debug('objRecord-89', objRecord);
setFieldValuesLifftingBusiness(objRecord);
// Save the record
var recordId = objRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
log.debug('recordId-97', recordId);
}
log.debug('Outside of Conditions-99');
}
Please let me know the solution to it. This is a production issue for us.
Best regards,
Shubham Singh