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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 118

#2
CP04-islander Profile Picture

CP04-islander 80

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 64 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans