Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Suggested answer

how to collect value from javascript when fields present on form from other entity

Posted on by 812

Hi when we use quickview form we generally follow this


var quickViewControl = formContext.ui.quickForms.get("quickviewname");
var myValue = quickViewControl.getControl("internalname").getAttribute().getValue();

This works totally fine. But now work order form of customer is embedded in booking. and this work order customer form is main form, and i am not able to extract it's value on booking form. Can someone help how do i extract value by javascript.

Thank you

  • Suggested answer
    Alejandro Cesetti Profile Picture
    Alejandro Cesetti 205 on at
    RE: how to collect value from javascript when fields present on form from other entity

    After working with MS support they provided the code that should work for PCF Form Component:

    //this value defines if the control was already loaded. I added a 1 because I have the field twice in the form

    var wasContentLoaded = formContext.getControl("regardingobjectid1").isLoaded();

    if (wasContentLoaded && formContext.getControl("regardingobjectid1").data.getIsDirty())

    {

    // if any field of the form component got updated

    var object = new Array();

    object[0] = new Object();

    object[0].id = formContext.data.entity.getId();

    object[0].name = formContext.data.entity.getPrimaryAttributeValue();

    object[0].entityType = formContext.data.entity.getEntityName();

    formContext.getControl("regardingobjectid1").data.entity.attributes.get("cus_phonecall").setValue(object);

    }

    In this example I am updating the cus_phonecall field from the related entity.

    This is working fine in my environments.

    I hope this helps!!

    Best,

  • Suggested answer
    antc Profile Picture
    antc 2,909 on at
    RE: how to collect value from javascript when fields present on form from other entity

    Anyone trying to this here is the JS required:

    You can use the console to work out the names or index to use.

    var info = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("msdyn_instructions").getValue();
    The above example is using the tab 3, section 0, Control 0 to get the Work Order attribute value and below can help during debugging in console:
    pastedimage1637566362881v1.png
  • Alejandro Cesetti Profile Picture
    Alejandro Cesetti 205 on at
    RE: how to collect value from javascript when fields present on form from other entity

    Hello Ravi!!

    Have you found a solution for this?

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: how to collect value from javascript when fields present on form from other entity

    Hi,

    When I checked the configuration it used Quick View Form only.

    <QuickForms><QuickFormIds><QuickFormId entityname="msdyn_workorder">613513a1-322d-4ecc-81bd-bd65640d834c</QuickFormId></QuickFormIds></QuickForms>

    Have you tried using same quick view JS code to retrieve the value?

    Yes it used PCF Form Component control to embed Work Order form and not using quick view form directly as we do it normally on form ->Insert->Quick View Form

    Please mark my answer verified if i were helpful

  • Ravi Fulani Profile Picture
    Ravi Fulani 812 on at
    RE: how to collect value from javascript when fields present on form from other entity

    I am using lookup present on bookable resource entityt form, just want to know if there is a direct way to get them like we can do for quick view, that would be easy and simple.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to collect value from javascript when fields present on form from other entity

    Hi Ravi,

    you mean that it took lookup field of work order, so you can use web Api to retrieve lookup entity by id to get value of the field you need.

    Refer this:

    https://community.dynamics.com/crm/b/passiondynamics/posts/get-lookup-value-from-other-entity-and-set-it-on-the-form-using-web-api-in-microsoft-dynamics-crm

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Ravi Fulani Profile Picture
    Ravi Fulani 812 on at
    RE: how to collect value from javascript when fields present on form from other entity

    There is work order customer and work order service forms are there, which recently have been introduced in Work order entity by microsoft teams.  Now these two forms are embedded in booking and work order form of Bookable resource booking entity. They took a lookup field of work order and added custom control in it which shows full form of work order form in booking entity's main form.

    pastedimage1599634567975v1.png

    pastedimage1599634724333v2.png

    pastedimage1599634950166v1.png

    if this would have been a quick view form I know how to extract the value.  I can edit these fileds in booking form as they are editable. All i need a way to abstrat their value via Javascript

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: how to collect value from javascript when fields present on form from other entity

    Hi,

    But now work order form of customer is embedded in booking. and this work order customer form is main form

    What do you mean by this?

    Can you please send screenshot of Booking form?

    I have checked booking form on my instance and I don't see any work order form embedded into it. How did you embedd work order form to booking form?

    Please mark my answer verified if i were helpful

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans