Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Unanswered

Opportunity Close Quick Create Form Onload is not working

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

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,353 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,251 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans