Readonly Lookup field

Readonly Lookup field

Postby ruiascensao » Wed Jun 12, 2013 9:12 pm

Hello,

I need to have a lookup field readonly after data input in a subform using Javascript.
Could someone please help me on this?

Thank You.
BR
Rui
ruiascensao
 
Posts: 177
Joined: Tue Nov 15, 2011 10:54 pm

Re: Readonly Lookup field

Postby massiws » Thu Jun 13, 2013 8:56 am

Rui, in the form you can add a function like this in Custom Code > Javascript:
Code: Select all
function lockField(id) {
    if($("#code"+id).val()) {
        $("#code"+id).attr("disabled","disabled");
        $("#luup_"+id).remove();
    }
}

and, on each lookup field you want to lock, in Lookup tab > Javascript insert this:
Code: Select all
lockField("your_field_name");

This will lock the lookup code field and remove the magnifying glass; if you need to edit the field, you have to save and reload the record again.

Hope this helps,
Max
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Readonly Lookup field

Postby ruiascensao » Fri Jun 14, 2013 6:28 pm

Cool!!!

Thank you.

BR
Rui
BR
Rui
ruiascensao
 
Posts: 177
Joined: Tue Nov 15, 2011 10:54 pm

Re: Readonly Lookup field

Postby massiws » Sat Jun 15, 2013 3:26 am

.
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy


Return to Custom Code



cron