web
You’re offline. This is a read only version of the page.
close
Skip to main content
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);
        }
    );
}

I have the same question (0)
  • 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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 231

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 83 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 68 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans