Forums

Forums / Developing Portals / Set a static lookup field with javscript

Set a static lookup field with javscript

2 posts, 0 answered
  1. Mike Cohen
    Mike Cohen avatar
    31 posts
    Registered:
    10 Aug 2021
    23 Oct 2023
    Link to this post
    I'm having trouble setting the value of a static lookup field using javascript. 

    I am using the following line of code:
        tpc.forms[0].new_crmaccount.set_value(crmaccount);
      
    and when I check this value from the console I see that it is populated. 
        tpc.forms[0].new_crmaccount.get_value();
       'account;<MYGUIDHERE>'

    When I submit this form, my crm rejects the submission. Are there other properties of this lookup field I need to set when I set it programatically? 

  2. Eric Mann
    Eric Mann avatar
    59 posts
    Registered:
    16 Oct 2020
    24 Oct 2023 in reply to Mike Cohen
    Link to this post
    Mike, 
    Yes, you need to use the "account;GUID" method for set_value in a lookup. Here's the documentation: https://www.crmportalconnector.com/developer-network/documentation/portal-connector-widgets/tpc-client-side-api/mvc-based/lookup 
    I believe it also obeys the encryption if you have that on the field so using your method of get_value should inform you of which type of GUID to use whether encrypted or not. 
2 posts, 0 answered