Forums

Forums / Developing Portals / after record is created, on portal form i have 3 fields which are hidden and they are visible only request is received from D365 CRM.

after record is created, on portal form i have 3 fields which are hidden and they are visible only request is received from D365 CRM.

2 posts, 1 answered
  1. pavankanth reddy ragiri
    pavankanth reddy ragiri avatar
    1 posts
    Registered:
    28 Jul 2020
    28 Jul 2020
    Link to this post
    after record is created, on portal form i have 3 fields which are hidden and they are visible only when request is received from D365 CRM. which is working fine and below is the code for it.
    now problem is, i have Subject option set field on form with 3 options enhancement, support and implementation. when record is creating i will select enhancement in subject form will be saved. after saving record if change subject to support or implementation and again back to enhancement hidden fields are showing on the form.
    please suggest how i can add my logic in below code.

    $(document).ready(function() {
    $('#new_activestage').hide();
    $('#new_activestage_label').hide();
    var activeStage=$("#new_activestage").val();
    var reqApproval=$("#new_requirementapproval").val();
    var estApproval=$("#new_estimationapproval").val();
    var uatApproval=$("#new_uatapproval").val();

    //Verifing for Estimation Approval
    if(activeStage.includes("Estimation Approval") || estApproval==1 || estApproval==2)
    {
    $('#new_estimationapproval').show();
    $('#new_estimationapproval_label').show();
    }
    else
    {
    $('#new_estimationapproval').hide();
    $('#new_estimationapproval_label').hide();
    }

    //Verifing for UAT Approval
    if(activeStage.includes("UAT Approval") || uatApproval==1 || uatApproval==2)
    {
    $('#new_uatapproval').show();
    $('#new_uatapproval_label').show();
    }
    else
    {
    $('#new_uatapproval').hide();
    $('#new_uatapproval_label').hide();
    }

    //Verifing for Requirement Approval
    if(activeStage.includes("Requirement Approval") || reqApproval==1 || reqApproval==2)
    {
    $('#new_requirementapproval').show();
    $('#new_requirementapproval_label').show();

    }
    else
    {
    $('#new_requirementapproval').hide();
    $('#new_requirementapproval_label').hide();

    }



    $('#subjectid').on('change', function() {  
    if ($('#subjectid').val() == "9d2581b4-41a0-e911-a994-000d3af29e21")

    {
    $('#new_requirementapproval').show();
    $('#new_requirementapproval_label').show();
    $('#new_estimationapproval').show();
    $('#new_estimationapproval_label').show();
    $('#new_uatapproval').show();
    $('#new_uatapproval_label').show();
    }
    else
    {
    $('#new_requirementapproval').hide();
    $('#new_requirementapproval_label').hide();
    $('#new_estimationapproval').hide();
    $('#new_estimationapproval_label').hide();
    $('#new_uatapproval').hide();
    $('#new_uatapproval_label').hide();
    }  
    })});
  2. Patrick
    Patrick avatar
    33 posts
    Registered:
    20 Apr 2020
    Answered
    04 Aug 2020 in reply to pavankanth reddy ragiri
    Link to this post
    Hi Pavankanth,

    The code you provided seems to hide or show certain fields on document ready, but when you change your subject selection you simply hide or show everything based on whether ID = "9d2581b4-41a0-e911-a994-000d3af29e21".

    You likely want to show/hide specific fields based on subject within your on change function.

    I'd also like to add that what you're trying to implement may be a good candidate for using our Rules Manger widget. You can create rules to handle hiding/showing form fields based on values of other fields. Here's a link to the documentation: 
    https://www.crmportalconnector.com/developer-network/documentation/portal-connector-widgets/tpc-form-widgets/mvc-based/rules-manager


    Thanks,

    Patrick
    Last modified on 06 Aug 2020 13:08 by Patrick
2 posts, 1 answered