Setting Field as selected in script?
I'm trying to set a calculated field to "1" if it is the only related record.
I have a raw materials table, suppliers table and a join table between them of rawmtrlsupplier.
While in raw materials table, user can add one or more suppliers for a particular raw material, and see this in a related portal. In the portal of suppliers I have a field "rawmtrls_RAWMTRLSUPPLIER:: _MainSupplierID" with a checkbox set that has a value list of "1". It also has a button applied to it as shown below:
Scripts: Set Default Supplier
Set Error Capture [ On ]
Set Field [ RawMtrls::_kf_DefaultSupplierID; rawmtrls_rawmtrlsupplier_SUPPLIER::__kp_SupplierID ]
It also has a calculation assigned to it which is:
How do I enable the checkbox being automatically selected when there is only one supplier in the portal?
Right now the user can add a new supplier but if it is the only one in the portal then they also have to click on the field to select it as the main supplier. Seems counter intuitive to have to do this extra step if there is only one supplier in the portal.
I have tried scripting in a find to the RAWMTRLSUPPLIER to see if the particular raw material only has one supplier and then set the rawmtrls_RAWMTRLSUPPLIER:: _MainSupplierID to have a value of 1, but because it is a calculation field, I can't modify it.
What is a good way to approach this?