OnCellEdit() how can i write validation based on any other field value?

ashwanikumar
Tera Expert

Hi All,

 

FIELD VALIDATION:

As per the requirement I need to populate state field value based on country value in list view. i have made state field value dependent on country field.

now the problem is State field shows all the dropdown options when country is empty in the list view. i am writing the oncelledit script to resolve this issue. basically if country is empty script will not allow state value submission.

Now the challenge I am facing is that i am unable to get the country value within the onCellEdit script. g_form.getValue is not working. Is there any alternate ways to resolve it?

5 REPLIES 5

karthik120
Giga Expert

Hello,

Can't you do it using onchange client script? I guess you can. What do you mean by g_form.getValue() is not working? Please share the code to understand more.

 

Thanks!

Dubz
Mega Sage

onCellEdit doesn't have access to the form, it gives you some control over fields on a list but you can't do conditional stuff like this. To fulfill your requirement you can use a before insert/update business rule, set the condition to 'country is empty' and then in the actions tab tick the abort action box and add a message to your users.

 

find_real_file.png

Chuck Tomasi
Tera Patron

You might want to take a look at TechNow Ep 33 and use a GlideAjax call in your onCellEdit() client script. You can retrieve the current value of the country field.

 

BTW, as mentioned, when you are in a list, g_form (which works on the FORM) isn't available, that's why it doesn't work.

 

TechNow Episode List

Eloy Bayona - R
Tera Contributor

Hello,

I am trying to use an onCellEdit client script to take an action when the state field of the alm_hardware table is updated in the list view. Because the substate is dependent on the state field the two fields are changed at the same time on the list view and my onCellEdit client script appears to be calling the AJAX script include just fine, but the state/substate does not change. I have a very similar onCellEdit client script that does work for the substate field on its own and it calls the same script include.

 

Is there anything special required for onCellEdit to handle dependent field list edits?

 

Regards,

Eloy Bayona