Page 1 of 1

Readonly Lookup field

PostPosted: Wed Jun 12, 2013 9:12 pm
by ruiascensao
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.

Re: Readonly Lookup field

PostPosted: Thu Jun 13, 2013 8:56 am
by massiws
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

Re: Readonly Lookup field

PostPosted: Fri Jun 14, 2013 6:28 pm
by ruiascensao
Cool!!!

Thank you.

BR
Rui

Re: Readonly Lookup field

PostPosted: Sat Jun 15, 2013 3:26 am
by massiws
.