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
//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
Comments
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.
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.
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?
And if i click into the SR123897 and then click on activities the link is just. /ServiceRequest/Edit/SR123897#
I suspect you would have to do that every time it updates, and test, test.
Simple add "Line Manager Should Review" to the list of fields to hide.
Geoff
Line of code is from this discussion here: https://community.cireson.com/discussion/comment/3746#Comment_3746
I changed the function like this:
See my comment (Marked as Answer) on this thread
https://community.cireson.com/discussion/comment/3746#Comment_3746
Is that what you need?
Geoff
Check out https://community.cireson.com/discussion/1538/can-we-set-activity-fields-as-read-only-for-approvers#Item_1
Geoff
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...)
...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?
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
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
I suspect it is an issue with the %. However, the actual property name for that field is 'ApprovalPercentage'. Try that.
Geoff
That worked great on all languages!
Added Scheduled Start and End Date and it worked perfectly.
Thanks!
TVN
The 'ApprovalPercentage' is the wrong one.
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
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
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
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
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.
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();