Lookup field is something that it points to another entity or table.
To set the value, we should know the id of table record (which we want to set), name (record will have name value which contains text) and type of entity.
Say your lookup field logical name is myfieldname then you can set as below.
$("#myfieldname_name").attr("value","Name");
$("#myfieldname_id").attr("value","record_GUID");
$("#myfieldname_entityname").attr("value","entity_logicalname");
Or
$("#myfieldname_name").val("Name");
$("#myfieldname").val("record_GUID");
$("#myfieldname_entityname").val("entity_logicalname");
------------x----------------x-----------------------x--------------------x---------------------
Sometime we render lookup field as dropdown/options in portal UI.
The dropdown will have value as GUID of record id. To select the value, we need to set the GUID of the record in value for dropdown (Lookup rendered as dropdown).
You can use below code to set the value.
$("#myfieldnameid").val('GUID_of_Record').attr("selected",true);
No comments:
Post a Comment
Write us your comment.