HI all. I have a question that i think should have...
# general
j
HI all. I have a question that i think should have a simple answer, but I'm having trouble to create a solution. I want to create a custom transaction body field that is derived from a field in a custom table. I want the field to have a lookup capability similar to how a list/record field behaves with the lookup/pulldown available and only accept input that already exists in the custom record. I have tried several approaches, such as referencing a saved search and sourcing, but none seem to work. What am i missing?
n
@JR if I've understood your requirement correctly... You may have to create your custom field with no filtering/values. Write a UserEvent script to add a temporary SELECT type field, run your search etc to get the valid values, and use those values to populate your temporary field. Something like this:
Copy code
let recForm = context.form;
let newApp1Field = form.addField({
                    id:'custpage_approver1',
                    label:'Preferred Approver 1',
                    type:serverWidget.FieldType.SELECT,
                });

newApp1Field.addSelectOption({value:' ',text:''});
newApp1Field.addSelectOption({value:1,text:'Widget 1'});
You would hide the "real" field in EDIT mode in the same UE script
Copy code
let origApp1Field = form.getField({id:'custbody_preferred_appr_stage_1'});
origApp2Field.updateDisplayType({displayType:serverWidget.FieldDisplayType.HIDDEN});
and, on submit of the page, after the user has selected the value in the temporary field use that value to set the "real" field.
Copy code
let newApprover1 = tranRec.getValue({fieldId:'custpage_approver1'})||'';
if(newApprover1 !==''){                    tranRec.setValue({fieldId:'custbody_preferred_appr_stage_1',value:newApprover1});
                }
If I've misunderstood.. sorry try me on Friday as I'm off tomorrow 🙂
j
@NElliott Interesting! All i want is to replicate the behavior of a field that is of type list/record, with data is not readily available, since it's neither a list or record. I would have thought that using a saved search as the input would be easy and straight forward, but it doesn't appear that's an option. I'll look this through and see if this works for me. Thanks so much!