Form - Set field default value using Javascript

thiraj
Tera Contributor

Hi Team,

On the change request form, i have a field called "Change Owner". There is also a "company field" which is a reference to the company table. The company record has a field called "u_test" which is a user reference field. (It's like a company manager field with the managers name).

I want the "Change owner" field in the change request form to have the default value of "u_test" based on the company field.

How can this be done?

I have tried "javascript : current.change_owner = company.u_test"

But i did not get anything.

All help is appreciated.

Thank you

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

So, basically, you need to have to change_owner name based upon the company name. I think you can get it done through onChange() client, let's try and see if this helps.



function onChange(control, oldValue, newValue, isLoading) {


    var cmp= g_form.getReference('company', doAlert);


}


function doAlert(cmp) {


        g_form.setValue('change_owner', cmp.u_test);


}


View solution in original post

5 REPLIES 5

thiraj
Tera Contributor

Hi Guys,



Thank you all for the replies. All of you guys are correct with the Client script, unfortunately i can only select one correct answer. But all your answers are correct.



Thank you