Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Javascript Accessing Field from QuickViewForm

Posted on by 50

Hi All,

I'm trying to access a Quick View Form Field via Javascript.

I've checked that the form is loaded and i can get access to the object but i'm unable to access the field value

var formContext = executionContext.getFormContext();
var qvc = formContext.ui.quickForms.get("maintenantinfo");

if (qvc.isLoaded())
{

var birthday = null;
var x = qvc.getControl("birthdate")
birthday = qvc.getAttribute().getValue();

}

Then an error is thrown

Cannot read property 'getValue' of null

I've tried accessing the field directly to no success as well.

any help would be greatly appreciated

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Javascript Accessing Field from QuickViewForm

    Hi partner,

    Looks like "birthdate" is a custom field, so you need to use the complete name with its prefix. In default, the prefix of custom field is "new_".

    pastedimage1590735956362v1.png

    Regards,

    Leo

  • DarrenMog Profile Picture
    DarrenMog 50 on at
    RE: Javascript Accessing Field from QuickViewForm

    Thank Leo for reply.

    I did a copy an paste error on the form.

    My code is

    var formContext = executionContext.getFormContext();
    var qvc = formContext.ui.quickForms.get("maintenantinfo");
    if (qvc != undefined)
    {
    if (qvc.isLoaded())
    {
    debugger;

    var birthday = null;
    var x = qvc.getControl("birthdate")
    birthday = x.getAttribute().getValue();

    }

    }

    I can hit the object birthdate but when i try and get Value on X it throw the error

    Cannot read property 'getValue' of null

    Cheers

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Javascript Accessing Field from QuickViewForm

    Hi partner,

    You used the wrong varibale.

    You should use "x" to getAttribute, not "qvc", "qvc" is quick view form control, not the field.

    pastedimage1590714737238v1.png

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/getattribute.

    For example, I want to get the contact email from contact quick view form in account form, I will use the following code.

    pastedimage1590714945404v3.png

    //get field value from quick view form
    function getField(executionContext){
        formContext=executionContext.getFormContext();
        var qvc=formContext.ui.quickForms.get("contactquickform");
        if(qvc.isLoaded()){
            var email=null;
            var x=qvc.getControl("emailaddress1");
            email=x.getAttribute().getValue();
        }
        alert(email);
    }

    Best Regards,

    Leo

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans