Skip to main content

Notifications

Announcements

No record found.

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.

  • Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Opportunity Close Quick Create Form Onload is not working

    Helo Rajesh,

    What happens if you remove it from the OnChange event?

  • Rajeshvarma Profile Picture
    Rajeshvarma 40 on at
    RE: Opportunity Close Quick Create Form Onload is not working

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

  • Rajeshvarma Profile Picture
    Rajeshvarma 40 on at
    RE: Opportunity Close Quick Create Form Onload is not working
    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
                });
               
            }
        }
    }
  • Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Opportunity Close Quick Create Form Onload is not working

    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
    Rajeshvarma 40 on at
    RE: Opportunity Close Quick Create Form Onload is not working

    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
    Johao Larios 1,795 on at
    RE: Opportunity Close Quick Create Form Onload is not working

    Hello Rajesh,

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

    regards

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans