Dynamic Forms

IT MonkeyIT Monkey O.G.
edited May 2016 in Cireson Uploads
This script works with both service requests, but can be easily adapted to work with any work item class in the Cireson portal.

Service Request Project Forms

With this example, we use a TemplateId field in the Service Request class, and have it set to _PROJECT_.

When then show a customized tab for the project and hide the general tab. This way you can have a specific layout per work item based on the template id.

Installation

Simply extract and copy the contents of this zip to your customspace\custom.js file.

You will also need to make sure and set the template ID within your service request template that you are using as the target template/request type. You can do this by exporting the templates management pack and adding this property to the xml of the template:
<Property Path="$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.Workitem.ServiceRequest']/TemplateId$">ProjectRequest</Property>

Download the attached .zip file below.

Comments

  • PIERRE-LOUIS_DURRISPIERRE-LOUIS_DURRIS Customer Advanced IT Monkey ✭✭✭
    I am facing one issue using this code in production. When the work item is not closed, every things go right. When the work item is closed, the hiding function above is not check any more and we see all the tab even those which should be hiden regarding the area of the service request.
    Do you have a solution for this issue ? I have the same issue to add a custom task for closed items.
  • Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    Hi Pierre,

    Excellent question! The app.custom.formTasks section does not load for Closed Work Items; however, the custom.js file does still load. Try replacing this section of the code:


    app.custom.formTasks.add('ServiceRequest', null, function(formObj, viewModel){  
            formObj.boundReady( function () {
                    if(viewModel.TemplateId == 'ProjectRequest') {
                            fn_ShowTab("PROJECT", formObj)
                    }else{
                            fn_HideTab("PROJECT", formObj)
                    }
            });
    }); 


    With this:


    $(document).ready(function (){
            var url = window.location.href;
            if(url.indexOf("/ServiceRequest/Edit/") > -1){
                    setTimeout(function() { 
                            if(pageForm.viewModel.TemplateId == 'ProjectRequest') {
                                    fn_ShowTab("PROJECT", pageForm)
                            }else{
                                    fn_HideTab("PROJECT", pageForm)
                            }
                    },1500);
            }
    }); 


    Thanks,
    Nick
  • PIERRE-LOUIS_DURRISPIERRE-LOUIS_DURRIS Customer Advanced IT Monkey ✭✭✭
    Thanks Nick. This work well with the new code. Are we also able to have task for close item ? Print option for example ?
  • Steve_O'ConnorSteve_O'Connor Customer IT Monkey ✭
    Must be missing something, trying to implement this and it get this error:

    The management pack import failed.
    Errors (1):
    Failed to verify ObjectTemplate: Template.7682a488ec864f9eb2eff07b2ac591d2
    : Cannot find ManagementPackElement [Type=ManagementPackClass, ID=System.Workitem.ServiceRequest] in management pack ManagementPack:[Name=System.WorkItem.ServiceRequest.Library, KeyToken=31bf3856ad364e35, Version=7.5.3079.0].

    I've added the portion to the XML of the management pack then go to reimport and get that error :(

  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    Is it possible to have required fields on these additional forms and if so, how is it done?

    As it just hides the tabs, this may not be possible??

  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    edited July 2016
    Curious, what browser does everyone preference with the dynamic from solution? I seem to get difference results depending on browser, and also different again on new PR releases of the portal.
  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    This solution in v6 of the portal makes the "Is Private" checkbox unclickable. Just in case others get caught out this this.
  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    This functionality wasn't there on older versions of the portal either, however I never noticed. Where the "Is Private" checkbox in the acitonlog only works on the General tab,
  • Candice_YeudallCandice_Yeudall Customer Advanced IT Monkey ✭✭✭
    I have never really understood the use of the "Is Private" button given that if it is unchecked at anytime the comment will appear to all. As far as I am concerned all comments should be public consumable.
  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    File notes or analysts comments that you don't want to bother the end user with is perfect for the "is private" function.
  • Chris_JordanChris_Jordan Customer IT Monkey ✭
    When I change the position of;
    name: "FileAttachments",
    type: "fileAttachments"

    It displays very close to the nav side bar.



    Does anyone know how/if it's possible to have is aligned with the other columnFieldLists?
  • Tom_HydeTom_Hyde Customer Advanced IT Monkey ✭✭✭
    Must be missing something, trying to implement this and it get this error:

    The management pack import failed.
    Errors (1):
    Failed to verify ObjectTemplate: Template.7682a488ec864f9eb2eff07b2ac591d2
    : Cannot find ManagementPackElement [Type=ManagementPackClass, ID=System.Workitem.ServiceRequest] in management pack ManagementPack:[Name=System.WorkItem.ServiceRequest.Library, KeyToken=31bf3856ad364e35, Version=7.5.3079.0].

    I've added the portion to the XML of the management pack then go to reimport and get that error :(

    I'm getting the same issue. Could someone clarify where to add the property to the xml file, i expect i'm doing this wrong...
  • Thomas_PeterThomas_Peter Customer IT Monkey ✭
    Hi, the dynamic form works fine for me when using internet explorer, but using chrome the tab is not hidden. Seems to be that Chrome has a problem with the statement $("a[data-toggle='tab'").each . Does anyone else has the same issue? And if yes, any solution?
  • Tom_HendricksTom_Hendricks Customer Ninja IT Monkey ✭✭✭✭
    It is missing a square bracket, so it should have a problem with that statement.  This should work:

    $("a[data-toggle='tab']").each( ...rest of code...
  • Thomas_PeterThomas_Peter Customer IT Monkey ✭
    Thanks for your reply, the code is now 
    function fn_HideTab(name,form){
     console.log("This is a Standard Request: "  );
     $('a[data-toggle=tab]').each(function(){
      if(this.innerText === name){
       $(this).hide();
      }
     });
    }
    but still not working with chrome. I can see in the F12 log the text "This is a Standard Request", but the tab is still visible. Is it working for you with chrome?


Sign In or Register to comment.