Blog

JS: Access values of fields located on the “Form Component” PCF Control

Today during one of the work sessions with my colleague I found an interesting feature – it’s possible to access/work with related entity fields that are shown using “Form Component”. According to the documentation of “Form Component”, it’s possible but I was not able to locate any examples of it so if you’re curious how it could be performed check the following code:

Let’s say I’m on the “Account” form and I have the “Primary Contact” field configured using “Form Component”:

In order to access fields from the “Form Component” controls, it’s possible to use the following script:

Note: because it’s possible to place the same attribute of the form multiple times it would be required to use the proper index at the end of the control name – in my case I had attribute placed twice (first as regular lookup control – primarycontactid and the second time as a form component control – primarycontactid1).

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.