I am trying to create 2 dropdowns that are dependent upon each other. 1 is department (so they can look up by dept number) another is department description (can look up by dept desc).
What I need: [LIST=1]
[*]With SuiteScript 2.0 I need to create the dept description dropdown.[LIST=1]
[*]It doesn't need to show any options until a subsidiary has been selected.
[*]The first option should always be blank until dept or dept description is selected.
[*]I need to put it right after or below the department.
[/LIST]
[*]With both being dependent upon each other, I need to not get in an infinite loop in the fieldChanged. So if dept changes desc I don't need desc to try and change dept, and then dept to change dept desc again (infinite loop of fieldChanged).
[*](Optional:Would replace the above 2 and what I have) Get the department to be searchable by dept number and description.
[*](Dreamishly fanciful hope/prayer) Do we have the ability to replace NetSuite's default dropdown with a completely different one like Select2 :-D
[/LIST]What I have: [LIST=1]
[*]I have the dept desc dropdown created.
[*]If dept changes it updates dept desc. if dept desc changes it updates dept.
[/LIST]
//User Event Script function beforeLoad(context) { var thisForm = context.form; var deptDesc = thisForm.addField({ id: 'custpage_dept_desc_test', label: 'Department Description Testing', type: serverWidget.FieldType.SELECT, container: 'main', }); var mySearch = search.create({ type: "department", columns: ["custrecord_osm_department_description"] }); deptDesc.addSelectOption({ value: " ", text: "-Select an Option-", isSelected : false }); var myPagedData = mySearch.runPaged(); myPagedData.pageRanges.forEach(function (pageRange) { var myPage = myPagedData.fetch({index: pageRange.index}); myPage.data.forEach(function (result) { var desc = result.getValue("custrecord_osm_department_description"); var id = result.id; deptDesc.addSelectOption({ value: id, text: desc, isSelected : false }); }); }); } //Client Script function fieldChanged(context) { var po = context.currentRecord; if(context.fieldId == "custpage_dept_desc_test") { po.setValue("department", po.getValue("custpage_dept_desc_test")); } else if(context.fieldId == "department") { po.setValue("custpage_dept_desc_test", po.getValue("department")); } }