Hi,
I'm trying to put together a script on an entry form that will set a default value and disable a field based upon the users selection in another field using the fieldChanged() function. There are two possible fields that I can use to trigger the event with the values listed below.
Field ID - customform
Static/Internal ID (value) - 14 (Real Estate Company Form)
-
0r
-
Field ID - category
Static/Internal ID (value) - 15 (Real Estate Services Company)
All companies within this particular client category use the same custom form and vice versa, so I was unsure upon which field to base the function. The custom form is not preferred so the user must select the value. This appears to reload the form so I was unsure if I should use the pageInit() function.
When a user selects the value in either field listed above I want to set the values and disable these fields fields:
Field ID - custentity_oncor
Type - List
Static ID (value) - 2 (No)
-
And
-
Field ID - custentity_incostar
Type - List
Static ID (value) - 2 (No)
This is what I have but can't get it to work.
function rescompFieldChanged (type, name)
{
//Check to see if user selected "Real Estate Company Form".
if (name == 'custform') && (nlapiGetFieldValue('custform) == 14)
{
//Set the values.
nlapiSetFieldValue ('category' , 15)
nlapiSetFieldValue ('custentity_oncor' , 2)
nlapiSetFieldValue ('custentity_incostar' , 2)
//Disable the fields
nlapiDisableField ('custentity_oncor' , 2)
nlapiDisableField ('custentity_incostar' , 2)
}
}
Can you set a default value AND disable the field? Is there an easier way to do this? I was thinking that I could scrap the non-preferred custom form and use scripts to set defaults and disable fields from the preferred form, but there are 20 or so fields. Any help is greatly appreciated!!