web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Access field value from quick view and setValue in form field

(0) ShareShare
ReportReport
Posted on by 55

HI,

I am trying to get a field value from Quick View form and need to set that value in another field. In the main form properties I have added this js in event library and  in Event Handlers added sdk.formOnLoad to load this form onLoad.

I didnt do any event handlers in the fields where the value should set from quickview. I am able to access the quick view field and show in alert. But I couldn't set that value in the local field.

var Sdk = window.Sdk || {};
(function () {
    'use strict';
    // Code to run in the form OnLoad event
    this.formOnLoad = function (executionContext)
 {
        var formContext = executionContext.getFormContext();
        formContext.getAttribute("Nameblock").addOnChange(DisplayBlockId);
    }
    
    function DisplayBlockId(executionContext){
        var formContext = executionContext.getFormContext();
        var quickViewControl = formContext.ui.quickForms.get("BlockInformation");
        if(quickViewControl != undefined){
            if(quickViewControl.isLoaded()){
                var blockidvalue = quickViewControl.getControl("blockid").getAttribute().getValue();
                alert(blockidvalue);
                formContext.getAttribute("blocktest").setValue(blockidvalue);
            } else {
                // Wait for some time and check again
                setTimeout(DisplayBlockId10executionContext);
            }

        } else {
            formContext.getAttribute("blocktest").setValue("No value");
            return;
        }
        }
}).call(Sdk);

I am able to see the field value in alert but not able to set the accessed value in field.

I have the same question (0)
  • Indhu Profile Picture
    55 on at

    Looks like there is something in this line

           formContext.getAttribute("blocktest").setValue(blockidvalue);

    alert before this line is getting executed but alert after this line is not getting executed

  • Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at

    Hello Indhu,

    Can you give some information about the "type" of the source field and the field which you are trying to set ?

    Also please confirm that you are trying to get and set the value in same quick create form correct ?

    Thank you,

    Amit Katariya

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    I have tested the code your provided. It can work fine on my side. Do you have any error message?

    Here are some suggestions for you to troubleshoot it:

    1. Please make sure your field name is correct.

    2. It seems that blocktest field’s type is string and blockid field’s type is number. If so, please change your code formContext.getAttribute("blocktest").setValue(blockidvalue) to formContext.getAttribute("blocktest").setValue("" + blockidvalue) to have a try.

  • Indhu Profile Picture
    55 on at

    Steve Zhao  Amit Katariya007 

    the type of the source field "blockid" is whole number in quick view. I am trying to taking this field value which is in quickview, and set that value to another field - "blocktest" is whole number not in quick view.

    take the value from quick view and set it out of quick view.

    I am able to alert it but not able to set it in "blocktest" field

  • Indhu Profile Picture
    55 on at

    @Steve Zhao  @Amit Katariya007

    I tried something randomly and it helped.

    formContext.getAttribute("blocktest").setValue(blockidvalue)

    ---- changed to ----

    formContext.getControl("blocktest").getAttribute().setValue(blockidvalue).

    It worked

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans