Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Getting formContext after using Xrm.Navigation

Posted on by 10

I am trying to create a custom button to batch confirm invoices.  From the home grid in my Invoice entity, I am able to navigate to the selected Invoice forms.  From there, I would like to get the formContext and use the OOB function to confirm the invoices.  How am I able to get the formContext after navigating to the form using Xrm.Navigation?  If my button was on the form, I could use the CRM parameter PrimaryControl but I do not believe this will work since the button is on the home grid.  Below is my code.

function batchConfirm(selectedItems) {

var length = selectedItems.length;
var x = 0;

for (i = 0; i < length; i++) {
var selectedItem = selectedItems[i];
var id = selectedItem.Id;
Xrm.Navigation.navigateTo({ pageType: "entityrecord", entityName: "invoice", formType: 2, entityId: id }, { target: 1, position: 1, width: { value: 50, unit: "%" } }).then(
function success() {

},
function error() {
// Handle errors
}
);
}

}

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans