Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Unable to hide show fields in case form in uci 365 9.0

Posted on by 2,665

Hi All,

2 fields is present in case owner lookup & pending with  lookup to contact.In form owner field visibility marked as unchecked & pending with field visibility marked as checked.I have bpf on case & in bpf option set field Action there based on Action am show hiding these 2 fields.but sometimes its working when using BR & in js its giving undefined where i am showing d field.In BR also making these 2 fields locking if it contains data.

what could be d prblm hide show not working properly.

Below code using on load & on change of action but ShowHideField(formContext, "ownerid", true); show hide not working instaed showing undefined if using BR its working then again it fails for other options.

function lockBLStageFields(executionContext) {

    try {

        var formContext = executionContext.getFormContext();

        var formLabel = formContext.ui.formSelector.getCurrentItem().getLabel();

        if (GetFormType(formContext) == '2' && formLabel == "Case Overview - G&E") {

            if (formContext.getAttribute("mdc_action") != null)

                var action = formContext.getAttribute("mdc_action").getValue();

            if (action == null) {

                EnableDisableField(formContext, "header_process_mdc_businessleader", true);

                EnableDisableField(formContext, "header_process_mdc_approvedby", true);

                EnableDisableField(formContext, "header_process_mdc_approvaldate", true);

                EnableDisableField(formContext, "header_process_mdc_businessleadercomments", true);

                EnableDisableField(formContext, "header_process_mdc_additionalinformation", true);

                //SetRequirementLevel(formContext, "mdc_businessleadercomments", "none");

                this.reset(executionContext);

            } else if (action == 755040000) //Approve

            {

               

                //EnableDisableField(formContext, "header_process_mdc_action", true);

                EnableDisableField(formContext, "header_process_mdc_businessleader", true);

                EnableDisableField(formContext, "header_process_mdc_approvedby", true);

                EnableDisableField(formContext, "header_process_mdc_approvaldate", true);

                EnableDisableField(formContext, "header_process_mdc_businessleadercomments", false);

                EnableDisableField(formContext, "header_process_mdc_additionalinformation", false);

                //SetRequirementLevel(formContext, "mdc_businessleadercomments", "required");

                                                                setTimeout(function(){

                                                                formContext.ui.controls.get("ownerid").setVisible(true);                                                           

                                                                formContext.ui.controls.get("mdc_pendingwith").setVisible(false);

                                                                }, 3000);                                                              

                                                                //ShowHideField(formContext, "ownerid", true); //Show Owner

                                                                //ShowHideField(formContext, "mdc_pendingwith", false);

 

            } else if (action == 755040001) //Decline

            {

                //EnableDisableField(formContext, "header_process_mdc_action", true);

                EnableDisableField(formContext, "header_process_mdc_businessleader", true);

                EnableDisableField(formContext, "header_process_mdc_approvedby", true);

                EnableDisableField(formContext, "header_process_mdc_approvaldate", true);

                EnableDisableField(formContext, "header_process_mdc_businessleadercomments", false);

                EnableDisableField(formContext, "header_process_mdc_additionalinformation", false);                                               

                ShowHideField(formContext, "mdc_pendingwith", true);

                ShowHideField(formContext, "ownerid", false);

                

            } else if (action == 755040002) //Request Clarification

            {

                //EnableDisableField(formContext, "header_process_mdc_action", true);

                EnableDisableField(formContext, "header_process_mdc_businessleader", true);

                EnableDisableField(formContext, "header_process_mdc_businessleadercomments", false);

                EnableDisableField(formContext, "header_process_mdc_approvedby", false);

                EnableDisableField(formContext, "header_process_mdc_approvaldate", false);

                EnableDisableField(formContext, "header_process_mdc_additionalinformation", false);

              

            }

        }

    } catch (error) {

        var errorOptions = {

            details: "Error in CaseOverviewGE js, Method Name:lockBLStageFields().Download Error log file",

            errorCode: 13,

            message: error.message

        };

        Xrm.Navigation.openErrorDialog(errorOptions);

    }

}

Thanks,

Jharana

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to hide show fields in case form in uci 365 9.0

    Hi Jharana,

    I am glad your problem has been resolved.

    Thanks. 

    Regards,

    Leah Ju

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    Jharana Baliyar Singh 2,665 on at
    RE: Unable to hide show fields in case form in uci 365 9.0

    Hi Bipin,

    I cheked with control null still it was giving undefined so later when i did debug got this field was present in different tab in UCI becz of that it was not able to set hide show the field.

    Below code works fine now.

    formContext.getAttribute("fieldname").controls.forEach(

    function(control,i){

    control.setVisible(false);

    });

    )

    Thanks for the response..

    Thanks,

    Jharana

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Unable to hide show fields in case form in uci 365 9.0

    Hi,

    You should add check condition to check if control exist on form.

    if(formContext.getControl("new_endcustomer")!=null)

    formContext.getControl("new_endcustomer").setVisible(true);

    Also,

    Add debugger.Alert in your code to troubleshoot your issue.

    Also, By Default you should set false in Visisble By Default on Form field properties and then through JS code show or hide your field.

    Please mark my answer verified if i were helpful

  • Jharana Baliyar Singh Profile Picture
    Jharana Baliyar Singh 2,665 on at
    RE: Unable to hide show fields in case form in uci 365 9.0

    Hi Leah,

    that 2 fields are in form 2nd Tab.so no need to use header_process_schemaname here.

    formContext.getControl("new_endcustomer").setVisible(true); also have used sometimes its giving undefined & not working.

    Is there any way to show hide fields if those fields are already visibile set as unmarked means hiding in form.

    What is the best way to follow to hide show shold i show that 2 fields globally in form visibility section checked & then in code side will apply hide show ?

    Please let me know

    Thanks,

    Jharana

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to hide show fields in case form in uci 365 9.0

    Hi Jharana:

    1.Are your fields in main form?

    You need add prefix (header_ or header_process) in field when fields are in header or BPF.

    https://neilparkhurst.com/2016/08/07/javascript-work-with-fields-in-header-and-business-process-flow/

    2.You can use following code to set visible:

    formContext.getControl("new_endcustomer").setVisible(true);

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans