Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

CRM 2013 Account Active / Deactivate Issue

Posted on by 85

At the time of Activate account I want to disable all check-boxes. We have tried to put below code and though its not working.

Would you please let me know is there any other way we can do this?

if (saveMode == "6") {
if (Xrm.Page.ui.getFormType() == 4) {
Xrm.Page.ui.controls.get("new_xyz").setDisabled(true);

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

}

}

Thanks,

Vaibhavi P.

*This post is locked for comments

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Glad to hear it worked for you, Please make sure to close this thread.

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Thanks a lot for all help. I have used Xrm.Page.ui.refreshRibbon(); to refresh ribbon. Finally I am closing this one.

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    It worked. But somehow my page is refreshing but command bar and footer is not refreshing so is there any way to do this?

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Thanks .. I will try this and Let you know on this tomorrow.

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Hi,

    Your code is missing field check, Below is code to make new_chk disable if account is reactivated, Just tested this code working fine for me

    function OnSave(econtext) 
    {
     var eventArgs = econtext.getEventArgs();
    if (eventArgs.getSaveMode()== "5") {
    Xrm.Page.getAttribute("new_chk").setValue(1); //here you need to use your flag field
     }
    if (eventArgs.getSaveMode()== "6") {// to refresh form
    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    }
    
    }
    
    function Onload()
    {
    var chk=Xrm.Page.getAttribute("new_chk").getValue();// change this with your flag field
    
    if(chk==1) //disable checkbox
    Xrm.Page.ui.controls.get("new_chk").setDisabled(true);//change this with your checkbox that you want to disable
    }


    Let me know if you are facing any issue.

    Thanks

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    This is the code I have implemented on Page Load.

    function Form_onload() {

       if (HasAdministratorRole()) {

           Xrm.Page.getControl("new_xyz").setDisabled(false);

       } else {

           Xrm.Page.getControl("new_xyz").setDisabled(true);

       }

    }

    This below code I have written on Save.

    function Form_onsave(econtext) {

    if (econtext != null && econtext.getEventArgs() != null) {

           var saveMode = econtext.getEventArgs().getSaveMode();

           if (saveMode == "5") { //If Deactivate the Account

             //No Code

           }

           else if (saveMode == "6") {

    if (Xrm.Page.ui.getFormType() == 4) { //If Activate the Account

                Xrm.Page.ui.controls.get("new_xyz").setDisabled(true);

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

      }

      }

        }

    }

    Please let us know in case you need more Information.

    Thanks,

    Vaibhavi P

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Have you already created this field, I don't see any field checking in your code, share your complete code here and description.

    Thanks

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Yes that's the issue, Thanks for your suggestion. We are having Disable functionality implemented on Page Load for Check-boxes, So I might be wrong but the solution you gave its the same what I am doing currently.

    Do you have any other way? or Do you really think to implement the same way you suggested.

    please let me know your thoughts.

    Thanks,

    Vaibhavi p

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Ok,

    Thank you for providing more information Vaibhavi, As I understand you want when you reactivate any deactivated account it's checkbox should be disabled only ?? Is this what you want to implement ??

    For that you need to keep some flag in account entity (a custom field, you can keep two optionset, let's call it reactivated, which will have two option yes and no) . At the time of reactivate you need to set this flag, you can use workflow to set this flag, once this is set your js code can check if this field is true (onload event) which means this account is reactivated and then your disable checkbox with js code.

    Thanks

  • Vaibhavi P Profile Picture
    Vaibhavi P 85 on at
    RE: CRM 2013 Account Active / Deactivate Issue

    Thanks for your reply.

    On Account Entity in CRM 2013, There is a functionality of Activate / Deactivate Account. So basically when I Deactivate the account and again I activate the same account at that time I want that my all check-boxes should be disable. We have a code where we are enabling / disabling check-boxes. But the same code isn't working for Activate / deactivate scenario. So what I tried that, I have put above mentioned code at the time of Activate the Account but its not working. So i need to know is there any other way I can perform this?

    Please let me know in case you need more information or clarification.

    Thanks,

    vaibhavi P

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans