Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript - Set Required level doesn't work in Dynamic CRM Save

(0) ShareShare
ReportReport
Posted on by 80

Hi Experts,

I am facing strange issue, My scenario is I have dropdown on Task form, which is bydefault set hidden, on the Click of "Mark Complete" (SaveMode = 58) ribbon button, I am setting this dropdown visible "true" and making "business required".

Its working fine when user clicks on Mark complete button, field started showing with Business required property.

Suppose this time user click Save button instead "Mark Complete" he will still must have to fill that dropdown, but I don't want this.

On the click of Save button I am setting that dropdown visible false and setting business required as none, this code is not reflecting in the form, I debugged code is hitting properly onsave but its not reflecting.

Can anyone please suggest how should I handle this type of situation.

Thanks

*This post is locked for comments

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Javascript - Set Required level doesn't work in Dynamic CRM Save

    have your written anything for the mark complete button as well?If yes then please share that as well?

    Also, can you tell me what is your actual business requirement?

  • Shubh_K Profile Picture
    Shubh_K 80 on at
    RE: Javascript - Set Required level doesn't work in Dynamic CRM Save

    Hi Ravi,

    Followed your approach, Now i am not setting dropdown business required instead setting setVisible true and false based on the SaveMode. Here again a strange issue.

    1. When I am clicking on "Mark Complete" getting the alert message I set and dropdown is visible now.

    2. Then when I am clicking on "Save" dropdown is getting hide.

    3. Now Again When I am clicking to "Mark complete" nothing is happening :-(

    4. Now When I am clicking Save button getting alert which I have written for "Mark Complete" button. (Strange- Ideally I should not get this alert message)

    5. Now Onwards Mark Complete is not working even not hitting dubugger and  "Save" button started acting like mark complete button because in the debugging its showing SaveMode 58.

    I really don't know what and why this is happening, my code is pretty simple.

    function onSave(executionContext) {  

        var result;

        var taskstatus = Xrm.Page.getAttribute('new_status');

         Xrm.Page.getControl('exch_status').setVisible(false);

        //taskstatus.setRequiredLevel("none");  

           var eventArgs = executionContext.getEventArgs();    

           var saveMode = eventArgs.getSaveMode();

           //Mark Complete

           if (saveMode === 58) {                              

                 Xrm.Page.getControl('new_status').setVisible(true);                  

                 //taskstatus.setRequiredLevel("required");  

                    if(taskstatus.getValue())

                       {

                          result = taskstatus.getValue();                      

                       }

                       else

                       {

                           alert('Please Select the status');

                           eventArgs.preventDefault();

                           window.Mscrm.CommandBarActions.$P = false;  

                           return false;

                       }                

                   }

    }

    Thanks

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Javascript - Set Required level doesn't work in Dynamic CRM Save

    Hi,

    If you have marked the field as business required then it will be required for all. Instead you could just show hide on the mark complete and then add additional script on save which check if the save mode is mark complete, if yes and the dropdown is now selected then display a notifications.

    Hope this helps.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,492 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans