Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

how to open a new form through a ribbon button click and populate it in Javascript Dynamics 365 CRM

Posted on by Microsoft Employee

my code is supposed to take info from the context and open a new form to populate it 

i tried with xrm.page and formContext but didnt work

heres my code i dont know why its not working and in the debugger it says there's something wrong with populating the optionset

function CreateAndPopulateNewBackupDetailsForm(Context)
{
    
    var formContext = Context;
    var name = formContext.getAttribute("firstname").getValue();
    var addressName = formContext.getAttribute("address1_name").getValue();
    var mobilephone = formContext.getAttribute("mobilephone").getValue();
    var email = formContext.getAttribute("emailaddress1").getValue();
    var faxNumber = formContext.getAttribute("fax").getValue();

    var entity = {};
    entity.alf_name = name;
    entity.alf_address = addressName;
    entity.alf_email = email;
    entity.alf_telephone = mobilephone;
    entity.alf_fax = faxNumber;
    entity.getControl("alf_contact").getAttribute().getValue();

    Xrm.WebApi.online.createRecord("alf_backupdetails", entity).then(
        function success(result) {
            var newEntityId = result.id;
        },
        function(error) {
            Xrm.Utility.alertDialog(error.message);
        }
    );
}

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to open a new form through a ribbon button click and populate it in Javascript Dynamics 365 CRM

    Hi,

    Is the formContext obtained correctly?

    Getting Dynamics 365 formContext from Ribbon Workbench | Magnetism Solutions | NZ (Auckland, Wellington, Christchurch and Dunedin)

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans