web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by 2,667

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Jharana Baliyar Singh Profile Picture
    2,667 on at

    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
    Bipin D365 Profile Picture
    28,985 Moderator on at

    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

  • Suggested answer
    Jharana Baliyar Singh Profile Picture
    2,667 on at

    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

  • Community Member Profile Picture
    on at

    Hi Jharana,

    I am glad your problem has been resolved.

    Thanks. 

    Regards,

    Leah Ju

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 60 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans