Home Cireson Uploads
image


IT Monkey will place code here as examples of what Cireson's consulting team has to offer as well as examples for public consumption to benefit the Microsoft System Center community as a whole.

DISCLAIMER

All files and projects located here come as is and without any warranty or support. We will attempt to improve the projects as time goes on based on customer and community demand. Comments and improvements are welcome as well as customization requests. Your use of these Cireson Uploads is subject to our Terms of Use.


Cireson's support team has no information on these projects outside of what you have available and will not provide support for these enhancements, extensions, and scripts.

Dont forget to checkout solutions uploaded by our customers, partners and community members here.

Hide Activity Fields

IT MonkeyIT Monkey O.G.
edited September 2022 in Cireson Uploads
Provides the code to hide fields on activities. This is dynamic and you can add additional field names as desired.

*Currently only works for Service Requests but can be easily adapted to support Change Requests*

//start hide activity fields
app.custom.formTasks.add('ServiceRequest', null, function(formObj, viewModel){  
      formObj.boundReady(function () {
            var targetFields = [
                  "Area",
                  "Priority",
                  "Stage",
                  "Scheduled Start",
                  "Scheduled End",
                  "Impacted Configuration Items"
            ]
            
            fn_HideActivityFields(targetFields);
      });
});
      
function fn_HideActivityFields (fields) {
    $("div.panel-heading:contains('Activities')").parent().on("mouseenter", function (){
        console.log("I'm hiding fields!", fields);
        for(var i=0; i < fields.length; i++){
                var label = fields[i];
                var item = $("div.activity-item-form").find("label span:contains(" + label + ")");
                $(item).each(function () {
                    var ctrl = $(this).parents("div")[2];
                    $(ctrl).hide();
                });
        }  
    });
}
//END hide activity fields

This is now available as an Add-In.

https://kb.cireson.com/article/user-guide-add-in-hide-activity-fields/2616
«1

Comments

  • Xiaoqian_LiXiaoqian_Li Customer IT Monkey ✭

    We won't be able to hide MA "Actual Start Date" and "Actual End Date" ("Actual Start"/"Actual End") since it is not shown on SCSM console. And found out that Data-control-bind="ActualStartDate" data-control-to="ScheduleEndDate". Please help. Thank you.

  • PIERRE-LOUIS_DURRISPIERRE-LOUIS_DURRIS Customer Advanced IT Monkey ✭✭✭
    Just for information, this work only for english language as we are working on description and not field.
    I had to fill the exact description in french to be able to hide these fields. You need to hide field for each language.
    I have been able to fill Actual Start Date and Actual End Date with the full french description.
    The check to hide field seems also to be case sensitive.
  • Xiaoqian_LiXiaoqian_Li Customer IT Monkey ✭
    Thank you for the clue. It is case sensitive. This works after using "Actual start" and "Actual end".
  • Leigh_KildayLeigh_Kilday Member Ninja IT Monkey ✭✭✭✭

    We would like to hide Line Manager Should Review. I've tried a few combinations for this field and haven't been successful so far. Has anybody got a solution for this?

  • Thomas_StrombergThomas_Stromberg Premier Partner Advanced IT Monkey ✭✭✭
    Have anyone found a way to make this work if you click on a MA for example direct in the view? If you do that the hide fields does not work. When i click on an activity direct from my workitems i get the link /ServiceRequest/Edit/SR123897?activityId=MA123899&tab=activity

    And if i click into the SR123897 and then click on activities the link is just. /ServiceRequest/Edit/SR123897#

  • AJ_WittenbrinkAJ_Wittenbrink Customer Adept IT Monkey ✭✭

    We would like to hide Line Manager Should Review. I've tried a few combinations for this field and haven't been successful so far. Has anybody got a solution for this?

    I will say an unsupported way would be to comment out that section in the HTML [C:\inetpub\CiresonPortal\Scripts\app\templates\activity].

    I suspect you would have to do that every time it updates, and test, test.
  • Eugen_MuellerEugen_Mueller Customer IT Monkey ✭
    Great!!!!!!!
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    @Leigh_Kilday

    Simple add "Line Manager Should Review" to the list of fields to hide.

    Geoff
  • Dennis_de_JagerDennis_de_Jager Customer IT Monkey ✭
    I have actually included the hiding of the Approve and Reject All buttons.
    Line of code is from this discussion here: https://community.cireson.com/discussion/comment/3746#Comment_3746

    I changed the function like this:


    //Hide activity Fields and Buttons Function&nbsp;<div>function fn_HideActivityFields (fields) {</div><div>&nbsp; &nbsp; $("div.panel-heading:contains('Activities')").parent().on("mouseenter", function (){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; console.log("I'm hiding fields!", fields);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(var i=0; i < fields.length; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var label = fields[i];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var item = $("div.activity-item-form").find("label span:contains(" + label + ")");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(item).each(function () {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var ctrl = $(this).parents("div")[2];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(ctrl).hide();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div><div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;</div><div>		//Hide the Approve an Reject All</div><div>		console.log("I'm hiding CR Approve and Reject All buttons!");</div><div>		$('div[class=reviewer-controls]').hide()</div><div>		</div><div>&nbsp; &nbsp; });</div><div>}</div><div>//END hide activity fields</div>
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Makes sense to bundle into one. Stay tuned for a new solution I will post tonight to help with Activities.
  • Aaron_BoockAaron_Boock Customer Advanced IT Monkey ✭✭✭
    How can I disable the fields, or a specific field, rather than hide?  Similar to disabled:true in one of the json work item templates
  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    Makes sense to bundle into one. Stay tuned for a new solution I will post tonight to help with Activities.
    Hi @Geoff_Ross, is there a solution for hiding the Approval All/Reject All that leaves the regular approve/reject buttons in place?
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    @Jonathan_Boles
    See my comment (Marked as Answer) on this thread

    https://community.cireson.com/discussion/comment/3746#Comment_3746

    Is that what you need?
    Geoff
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    @Aaron_Boock Just seen your question above about disabling instead of hiding.

    Check out https://community.cireson.com/discussion/1538/can-we-set-activity-fields-as-read-only-for-approvers#Item_1

    Geoff
  • Adrian_SaloneAdrian_Salone Partner IT Monkey ✭

    A different approach - hide runbook activities and disable the toggle on manual activities.  Means that the end user can only drill into Review Activities:

    $(document).ready(function(){
     $( "div.activity-item-header[data-activity-id^=RB]" ).hide();
     $( "div.activity-item-header[data-activity-id^=MA]" ).next( "div.activity-item-body" ).attr( "data-for-action", "" );
    });

    (Bear in mind, I still need to target the above code to run only for users without analyst rights...)

  • Adrian_SaloneAdrian_Salone Partner IT Monkey ✭

    ...continued from previous post...

    ...except the js code directly above doesn't seem to have the desired effect when added to custom.js, it only seems to work when running in the debug console (F12).

    I can see that the function is being executed but my current theory is that something else is coming along afterwards and trouncing any of the function's changes.

    Am I making some noob mistake here?

  • Dennis_de_JagerDennis_de_Jager Customer IT Monkey ✭
    I have adjusted the Script example in the above with this code just after hiding the Approve and Reject All buttons:

    <div>//start hide SR activity fields</div><div>app.custom.formTasks.add('ServiceRequest', null, function(formObj, viewModel){ &nbsp;</div><div>&nbsp; &nbsp; &nbsp; formObj.boundReady(function () {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var targetFields = [</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Area",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Priority",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Stage",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Scheduled Start",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Scheduled End",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Impacted Configuration Items",</div><div>				 &nbsp;"Line Manager Should Review"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fn_HideActivityFields(targetFields);</div><div>&nbsp; &nbsp; &nbsp; });</div><div>});</div><div>&nbsp;</div><div>//start hide CR activity fields</div><div>app.custom.formTasks.add('ChangeRequest', null, function(formObj, viewModel){ &nbsp;</div><div>&nbsp; &nbsp; &nbsp; formObj.boundReady(function () {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var targetFields = [</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Area",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Priority",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Stage",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Scheduled Start",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Scheduled End",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Impacted Configuration Items",</div><div>				 &nbsp;"Line Manager Should Review"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fn_HideActivityFields(targetFields);</div><div>&nbsp; &nbsp; &nbsp; });</div><div>});</div><div><br></div><div>//Hide activity Fields and Buttons Function&nbsp;</div><div>function fn_HideActivityFields (fields) {</div><div>&nbsp; &nbsp; $("div.panel-heading:contains('Activities')").parent().on("mouseenter", function (){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; console.log("I'm hiding fields!", fields);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; for(var i=0; i < fields.length; i++){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var label = fields[i];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var item = $("div.activity-item-form").find("label span:contains(" + label + ")");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(item).each(function () {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var ctrl = $(this).parents("div")[2];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(ctrl).hide();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div><div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;</div><div>		//Hide the Approve an Reject All</div><div>		console.log("I'm hiding RA Approve and Reject All buttons!");</div><div>		$('div[class=reviewer-controls]').hide()</div><div>		</div><div>		//Hide Runbook Activities for End Users</div><div>		if (session.user.Analyst !== 1) {</div><div>		console.log("I'm hiding Activites for End Users!");</div><div>		$( "div.activity-item-header[data-activity-id^=RB]" ).hide();</div><div>		$( "div.activity-item-header[data-activity-id^=MA]" ).next( "div.activity-item-body" ).attr( "data-for-action", "" );	</div><div>		}</div><div>		</div><div>&nbsp; &nbsp; });</div><div>}</div><div>//END hide activity fields</div><div></div>
    As always the code gets jacked up when pasting, so adding the code as attachment as well.
  • Tom_Vidar_NøklebyTom_Vidar_Nøkleby Customer IT Monkey ✭
    Just for information, this work only for english language as we are working on description and not field.
    I had to fill the exact description in french to be able to hide these fields. You need to hide field for each language.
    I have been able to fill Actual Start Date and Actual End Date with the full french description.
    The check to hide field seems also to be case sensitive.
    Been trying to hide this in other languages than English, without luck. Do i use the name of the field as it is presented in the portal? Or do i have to find this description you are mentioning some other place? If so, where do i find it?
  • Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
     Hi Tom,

    Localization can be done in the Portal by using the localization keys in the following format:

    localization.NameOfKey

    The names of the keys can be found by admins in the Localization section of the Portal.

    For this exact customization, I have attached a fully localized example which will work in every language. Additionally, the attached example uses a new-and-improved method of triggering the customization. Rather than triggering on a MouseEnter event, it is triggering using a mutation observer. The mutation observer method is a more effective way of applying changes to a page whose content is not immediately available. 

    Give the attached a shot, and let me know how it goes or if you have any questions!

    Thanks,
    Nick
  • Adrian_ProbstAdrian_Probst Premier Partner IT Monkey ✭
     Hi Tom,

    Localization can be done in the Portal by using the localization keys in the following format:

    localization.NameOfKey

    The names of the keys can be found by admins in the Localization section of the Portal.

    For this exact customization, I have attached a fully localized example which will work in every language. Additionally, the attached example uses a new-and-improved method of triggering the customization. Rather than triggering on a MouseEnter event, it is triggering using a mutation observer. The mutation observer method is a more effective way of applying changes to a page whose content is not immediately available. 

    Give the attached a shot, and let me know how it goes or if you have any questions!

    Thanks,
    Nick
    Hi Nick

    The attached code works perfectly, thanks!

    One question:
    When I put in the field "Approval Threshold (%)" (Key Name: ApprovalThreshold%) into the target fields, it doesn't work - and not only for this field, if this is added all other fields are shown again.

    Is there maybe a problem with the '%' character?

    Thanks for your help,
    Adrian
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Hi Adrian,

    I suspect it is an issue with the %. However, the actual property name for that field is 'ApprovalPercentage'. Try that.

    Geoff
  • Tom_Vidar_NøklebyTom_Vidar_Nøkleby Customer IT Monkey ✭
     Hi Tom,

    Localization can be done in the Portal by using the localization keys in the following format:

    localization.NameOfKey

    The names of the keys can be found by admins in the Localization section of the Portal.

    For this exact customization, I have attached a fully localized example which will work in every language. Additionally, the attached example uses a new-and-improved method of triggering the customization. Rather than triggering on a MouseEnter event, it is triggering using a mutation observer. The mutation observer method is a more effective way of applying changes to a page whose content is not immediately available. 

    Give the attached a shot, and let me know how it goes or if you have any questions!

    Thanks,
    Nick
    Hi Nick,

    That worked great on all languages!
    Added Scheduled Start and End Date and it worked perfectly.
    Thanks!

    TVN
  • Adrian_ProbstAdrian_Probst Premier Partner IT Monkey ✭
    Hi Adrian,

    I suspect it is an issue with the %. However, the actual property name for that field is 'ApprovalPercentage'. Try that.

    Geoff
    Hi Geoff

    The 'ApprovalPercentage' is the wrong one.


    Adrian
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Hi Adrian,

    Sorry, I've looked at the code and its actually looking for a element where the label contains the provided text. Therefore, try just 'Approval Threshold'

    Geoff
  • Adrian_ProbstAdrian_Probst Premier Partner IT Monkey ✭
    Hi Geoff

    That's what I tried first ;)
    But I think on the RA form is the "ApprovalThreshold%" used. Only for this Key is the translation correct.
    If there is the "ApprovalThreshold" used, I should see "_Genehmigungsschwellenwert (%)" in the portal:


    Adrian
  • Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    Hi Adrian,

    The "ApprovalThreshold%" key is indeed being used on the RA form. It is an odd key in that it has a non-alphanumeric character in the key, which JavaScript doesn't like. I don't know of a way to directly escape that character using the localization.NameOfKey approach, but since the "(%)" part is consistent across most languages, and the "ApprovalThreshold" key is likely similar, you could do this:

    var targetFields = [         localization.Area,         localization.Priority,         localization.Stage,         localization.ImpactedConfigurationIte,         localization.LineManagerShouldReview,         localization.ApprovalThreshold + "(%)" ]

    As Geoff mentioned, this code is not looking for an exact match either, so as long as you have a portion of the label present, it will work.

    Thanks,
    Nick
  • Adrian_ProbstAdrian_Probst Premier Partner IT Monkey ✭
    Hi Nick

    I found the problem:
    The "localization.ApprovalThreshold" key didn't work because there is a completely other Display String in German. I change this in the settings to the same string as the "localization.ApprovalThreshold%".
    Now it works perfectly!

    Thanks for your help!
    Adrian
  • Tim_ShackletonTim_Shackleton Customer IT Monkey ✭
    This is a great script!  How would I target properties just in MAs to hide rather than blanket all child activities?
  • Tim_ShackletonTim_Shackleton Customer IT Monkey ✭
     Hi Tom,

    Localization can be done in the Portal by using the localization keys in the following format:

    localization.NameOfKey

    The names of the keys can be found by admins in the Localization section of the Portal.

    For this exact customization, I have attached a fully localized example which will work in every language. Additionally, the attached example uses a new-and-improved method of triggering the customization. Rather than triggering on a MouseEnter event, it is triggering using a mutation observer. The mutation observer method is a more effective way of applying changes to a page whose content is not immediately available. 

    Give the attached a shot, and let me know how it goes or if you have any questions!

    Thanks,
    Nick

    This is great, but to get it working in my environment (7.4) I had to swap

    loadScript("/CustomSpace/HideActivityFields/HideActivityFields.js");

    for

    $.getScript("/CustomSpace/HideActivityFields/HideActivityFields.js");

    in the custom.css file.
  • Brad_HayesBrad_Hayes Member IT Monkey ✭

    I also found that hiding all Parallel Activities and Sequential Activities cleaned up the activity listing
    As we only use these activities to order the tasks and they are never assigned there was no issue in hiding them...

    /**************************************************************/
    /*** Hide all Parallel and Sequential activities for all users ***/
    /**************************************************************/
    console.log("Hiding Parallel Activities and Sequential Activities");
      $( "div.activity-item-header[data-activity-id^=PA]" ).hide();
      $( "div.activity-item-header[data-activity-id^=SA]" ).hide();

Sign In or Register to comment.