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 CRM (Archived)

how to save the form automaticaly when click on ribbon button

(0) ShareShare
ReportReport
Posted on by 5,514

6318.auto.PNG

when i click on approve button the form should automaticaly save how to do it

*This post is locked for comments

I have the same question (0)
  • sandeepc Profile Picture
    5,514 on at

    AlertButtonMsg("Examination Schedule Approved.", "SUCCESS", saveform);

  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    Hi,

    You can save the form first on click of button by calling the javascript function which utilizes following Xrm method:

    Xrm.Page.data.entity.save();

    Thanks

    Ajyendra

  • sandeepc Profile Picture
    5,514 on at

    function approved() {

       debugger;

       var Approved = Xrm.Page.getAttribute("sis_examinationstatus").getValue();

       if (Approved != 2) {

           var ExaminationsubGrid = Xrm.Page.getControl("Examination").getGrid().getRows();

           var ExaminationSection = Xrm.Page.getControl("Sections").getGrid().getRows();

           var examinationgridlength = ExaminationsubGrid.getLength();

           var sectiongridlength = ExaminationSection.getLength();

           var allfieldspopulated = true;

           var fields = ["sis_name", "sis_session", "sis_exammaster", "sis_examtype", "new_examcategory", "sis_startdate", "sis_enddate", "new_examsection"];

           for (var i = 0; i < fields.length; i++) {

               if (Xrm.Page.getAttribute(fields[i]).getValue() == null) {

                   allfieldspopulated = false;

                   break;

               }

           }

           if (allfieldspopulated == true) {

               if (sectiongridlength != 0) {

                   var allsubject = Xrm.Page.getAttribute("sis_allsubjects").getValue();

                   if (allsubject == false) {

                       if (examinationgridlength != 0) {

                           Xrm.Page.getAttribute("sis_examinationstatus").setValue(2);

                           Xrm.Page.getAttribute("sis_examinationstatus").setSubmitMode("always");

                           Xrm.Page.getAttribute("sis_examinationstatus").fireOnChange();

                           AlertButtonMsg("Examination Schedule Approved.", "SUCCESS", saveform);

                                             Xrm.Page.data.entity.save();

                       }

                       else {

                           AlertButton("Please select Subject Exam.", "INFO");

                           Xrm.Page.getAttribute("sis_examinationstatus").setValue(1);

                           Xrm.Page.getAttribute("sis_examinationstatus").setSubmitMode("always");

                       }

                   } else {

                       Xrm.Page.getAttribute("sis_examinationstatus").setValue(2);

                       Xrm.Page.getAttribute("sis_examinationstatus").setSubmitMode("always");

                       Xrm.Page.getAttribute("sis_examinationstatus").fireOnChange();

                       AlertButtonMsg("Examination Schedule Approved.", "SUCCESS", saveform);

                   }

               } else {

                   AlertButtonMsg("Please select Section.", "INFO", saveform);

                   Xrm.Page.getAttribute("sis_examinationstatus").setValue(1);

                   Xrm.Page.getAttribute("sis_examinationstatus").setSubmitMode("always");

               }

           }

           else if (allfieldspopulated == false) {

               AlertButtonMsg("Please fill all required fields.", "INFO", saveform);

               Xrm.Page.getAttribute("sis_examinationstatus").setValue(1);

               Xrm.Page.getAttribute("sis_examinationstatus").setSubmitMode("always");

           }

       }

    }

    ///////////

  • sandeepc Profile Picture
    5,514 on at

    how to add that code into this code.@ajayendra singh

  • sandeepc Profile Picture
    5,514 on at

    i will mark as verified immediately if i get the answer now

  • ajyendra Profile Picture
    1,738 on at

    Did u Wrote function for saveForm which you used in AlertButtonMsg. if yes please share with us.

  • sandeepc Profile Picture
    5,514 on at

    no

  • ajyendra Profile Picture
    1,738 on at

    if you saveform is doing nothing but onlyfor save form then replace this  AlertButtonMsg("Examination Schedule Approved.", "SUCCESS", saveform); with AlertButtonMsg("Examination Schedule Approved.", "SUCCESS", function(){Xrm.Page.data.entity.save(); });

  • ajyendra Profile Picture
    1,738 on at

    Hi,

    One more suggestion in this line

    AlertButtonMsg("Please select Section.", "INFO", saveform);

    AlertButtonMsg("Please fill all required fields.", "INFO", saveform);

    why you provide saveform parameter in that it just a info alert as per my understanding we don't need that parameter.

    Thanks

    Ajyendra

  • sandeepc Profile Picture
    5,514 on at

    we haave ribbon button

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans