web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Opportunity Close Quick Create Form Onload is not working

(0) ShareShare
ReportReport
Posted on by 40

Hi Experts,

I customized Opportunity Close Form, When I Click on Status Reason as Canceled, Customised Option set values need to come on Form Onload.

But it is not working.Any reasons or I missed anything? Please help me in this.

I have the same question (0)
  • Johao Larios Profile Picture
    1,795 on at

    Hello Rajesh,

    Could you explain a little bit more and add images if possible. I'm not understanding your problem.

    regards

  • Rajeshvarma Profile Picture
    40 on at

    opp-close.pngHi Johao,

    I customised Opportunity Close Quick create Form.

    1.Added Field data type is optionset.

    2.Wrote java script--> based on Status reason I want to show newly created option set values.

    3.On change event code is working fine.

    4.Canceled option is default one while click on Close as lost button In the opportunity form..so that on form load,Canceled related options are not showing in the newly created option set.

  • Johao Larios Profile Picture
    1,795 on at

    Thanks Rajesh,

    Could you share the JS logic that you are using? 

    also an screenshot showing how this JS is registered?

    regards

  • Rajeshvarma Profile Picture
    40 on at
    function hideQuickViewFields(executionContext)
    {
        debugger;
        //validate executionContext
        if (executionContext.getFormContext() !== null && executionContext.getFormContext() !== undefined) {
            var formContext = executionContext.getFormContext();
            var stateCode = formContext.getAttribute("opportunitystatuscode").getValue();
            var control = formContext.ui.controls.get("new_opportunityclosecategory");
            var controlValues = control.getAttribute().getOptions();
            control.clearOptions();
            if (stateCode == opportunitystatuscodevalue) {
                control.removeOption(value);
                control.removeOption(value);
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
            }
          
            else if (stateCode == opportunitystatuscodevalue) {
                var control = formContext.ui.controls.get("new_opportunityclosecategory");
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
               
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
               
                control.removeOption(value);
                control.removeOption(value);
            }
            else if (stateCode == opportunitystatuscodevalue) {
                var control = formContext.ui.controls.get("new_opportunityclosecategory");
               
                control.removeOption(value);
                control.removeOption(value);
                control.addOption({
                    "text": "text",
                    "value": opportunityclosecategoryvalue
                });
               
            }
        }
    }
  • Rajeshvarma Profile Picture
    40 on at

    I have registered JS function name in the form Onload and Onchange event of  opportunityclosecategory field.

  • Johao Larios Profile Picture
    1,795 on at

    Helo Rajesh,

    What happens if you remove it from the OnChange event?

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans