Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
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

(0) ShareShare
ReportReport
Posted on by

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
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,190 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans