Use case: Users want to click one button to say that the question has been answered and that will 1) mark the question as read only (inactive) and 2) close the current popup form (which was opened from a model driven app via a JavaScript).
Reason: The reason I don't want to Navigate is that I need the user to land right back on the same location on the subgrid. They might be scrolled thru 50+ questions and Navigation is going to reset the subgrid and force them for every question to have to find it again. Too much pain.
What I have in place now is a custom Fx button "Answered" that can change the statuscode and status reason values, which addresses #1. Now how to close the popup without using the Navigation option?
What might the code be for this button to close the Inspection Question form, which will by doing so, show the form it was popped up from?
ChatGPT is recommending changing the code to JavaScript. Now trying to implement it.
I've create the new webresource (using the exact same Patch code that worked from above) and added the close current window code), updated the button to run on the new JavaScript code, published all customizations, but so far it's not doing anything.
function markQuestionAsAnswered() {
// Get the selected item
var selectedQuestion = Self.Selected.Item;
// Update the status and status reason using Patch
Patch('Inspection Questions', selectedQuestion,
{
Status: 'Status (Inspection Questions)'.Inactive,
statuscode: 'Status Reason (Inspection Questions)'.Answered
}
);
// Close the current popup form
window.parent.Xrm.Page.ui.close();
// Refresh the parent form to reflect the changes
window.opener.location.reload();
}
Clicking the Answered button and the form doesn't change. Doesn't change status. Doesn't close....
The Javascript is in the Code, within the Solution.....