Hi All,
I am new to scripting but am so far loving the things you can achieve. I have however run into an issue and cant work out what to do.
Basically I have 2 records (original and assessor) the assessor record is linked to the original record via the assessor name field, so that the assessor can be selected on the original record.
What I want to happen is when the assessor is selected on the original record that a script goes and checks 2 fields on the assessor record to see if the assessor requires QA, QA is defined on the assessor record by 2 fields (QA required - Integer number set to 3 & QA Counter - default to 1 and incremented until it = QA required value), if the QA counter is equal to the QA required field it should reset the counter on the assessor record, if it equals 1 or 2 or 3 then it increment the counters and set a field on the original record to true.
This probably doesn't read very well and I have added my code below which is giving me an exception error on the NlapiGetNewRecord function.
Hope someone can advise.
function updateAssessorField(type, fld) { if (fld=='custrecord_bsb_assessor') { var OrigRec = nlapiGetNewRecord('customrecord_bens_sandbox'); //Capture Original Record var AssRec = nlapiGetNewRecord('custrecord_bsb_assessor'); //Capture Assessor Record var QACount = AssRec.getFieldValue('custrecord_ass_qa_counter'); //Get Value of QA Count var QAMax = AssRec.getFieldValue('custrecord_ass_rep_to_qa'); //Get Value of QA Max if (QACount==1) { AssRec.setFieldValue('custrecord_ass_qa_counter', 2); //Set Counter on Assessor Record to 2 OrigRec.setFieldValue('custrecord_bsb_qa_required', 'T'); //Set QA required on original record to True } else if (QACount==2) { AssRec.setFieldValue('custrecord_ass_qa_counter', 3); //Set Counter on Assessor Record to 2 OrigRec.setFieldValue('custrecord_bsb_qa_required', 'T'); //Set QA required on original record to True } else if (QACount==3) { AssRec.setFieldValue('custrecord_ass_qa_counter', 1); //Set Counter on Assessor Record to 1 OrigRec.setFieldValue('custrecord_bsb_qa_required', 'T'); //Set QA required on original record to True } else if (QACount==QAMax) { AssRec.setFieldValue('custrecord_ass_qa_counter', 1); //Set Counter on Assessor Record to 1 } } }