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.
Create Request On Behalf Of - Radio Buttons and Text Change
Summary of customization:
(1) Rather than allowing the analyst to immediately type in the user picker, they must first choose that they want to create on behalf of:
(2) Once they pick Yes, the picker appears as usual; however, notice the "placeholder text" now reads "Search for User" instead of the default "Choose One..."
The code used to accomplish this is attached. It would need to be copied into your custom.js file (ideally using getScript or the loadScript method). If you don't want the feature in (1) above, you can comment out or delete lines 6-21. If you want to change the placeholder text, that can be done on line 24.
Two other tidbits outside of the attached code:
(3) The actual "Create Request On Behalf Of" text can be changed in the localization section of the portal. The key you would override is "CreateRequestonbehalfof." Note that the "Choose One..." change could also be done from the localization section using the "ChooseOne' key; however, changes to localizations are Portal-wide, which might not be desirable.
(4) Changing what results appear once you start typing can be configured in the Admin Settings portion of the Portal. The keys you would modify in this case are "UserQuery" and "GroupQuery." If there is a particular attribute unique to all your Distribution Groups, you can add them to these search filter settings to omit them.
Comments
This code should be added near the start of the function:
I didn't mean to replace the RequestOffering condition, but you can combine the two statements as you have done.
<div><br></div>
What could I be doing wrong?
There is a syntax error in the original upload at the top of the page. Line 24 is missing a semicolon.
I made some changes to the script and changed the radio buttons to a toggle.
/*************************************/
/*** Request on Behalf of Toggle ***/
/*************************************/
// Only load code on Request Offering page
$(window).load(function() {
if (document.URL.indexOf("ServiceCatalog/RequestOffering") === -1) {
if (!session.user.Security.CreateOnBehalf) return;
}
// Hide create request on behalf of picker by default
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').hide();
// Create toggle and append after the picker
var toggler_CBR = $('<button class="toggler">Switch...</button>');
toggler_CBR.appendTo('label.control-label:contains("' + localization.CreateRequestonbehalfof + '")');
// Set toggle function (Show Hide)
$("#button_CRB").button()
$("button.toggler").click(function() {
$Switch = $(this);
$Switch.toggleClass('off');
if ($Switch.is(".off")) {
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').show();
}
else {
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').hide();
}
});
// Change the placeholder text in the picker
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.k-input.search-combo').attr("placeholder", "Search for User")
});
The script as provided above is only partially localized, but it would be a fairly simple update to localize it the rest of the way. Note in the code that the text for "Create on behalf of" is referenced via localization key, not hard-coded text, i.e. - localization.CreateRequestonbehalfof. The same concept would need to be applied for "Yes," "No," and any other hard-coded text within the code.
You can view all Portal localizations, override localizations or add new localizations by clicking your name in the top-right, then selecting "Localizations." Either way, localizations are all referenced in code via localization.localizationkey.
You have to make sure the "Domain Users" AD Group is in your SCSM Users CI, then make sure it is populated in the Cache for the Portal.
The rendering is a little messed up in the latest version of the portal. Is it possible to get an updated version? Great modification btw
Thanks
Try adding this to your custom.css:
That did the trick for my environment, Thanks
We recently updated our version too, and had to make some changes. I cant remember what exactly :-/
Either way, here is our current code. (below)
This version also allows "Multiple users" to be selected, instead of just a single user.
By default you will not be able to pick multiple users, only yourself, or a user on behalf of...
However, to enable the "Multiple users" option on a specific form (after putting in this code below), ensure the first field in any RO is labelled "##Multiple Affected User Picker##". This field must be a query results picker, filtered to the appropriate user's (all users in our case).
Hopefully this helps.
--
So the overall code here was a bit overkill for our own environment (looks like you've done substantial customization for your org), however, it was enough to prove out that I could get it to work. :-) (I did add a paren and semi-colon at the very end ");" and then it worked.)
I tried commenting stuff out (like the explicit ROs you mention, and the CR stuff) and again, it continued to work on the whole. SO...here's what I came up with.
The difference seems to be this:
Your new code starts with
Whereas the old version starts with
The clincher seems to be with stating $(document).ready instead of $(window).load. I don't understand the code well enough to know why; I just recognized that this seemed a significant difference in the call.
Anyway, I updated your original code (that we've been using) with that new first statement and it works great!
I did find as with @Steve_Clarke that the formatting was goofed up (the radio buttons were way out to the right of the text labels), but the correction provided by @Nick_Flint for the 'custom.css' made all the difference.
Thank you so much for responding so quickly, and hats off to all of you for your various contributions. Great stuff! Cheers!
Stefan
Adrian
Hey all, I have applied this script below to my Custom.js and refreshed. When I open any of my request offerings the options are not showing up at all. Can anyone help me out with this?
/*************************************/
/*** Request on Behalf of Toggle ***/
/*************************************/
// Only load code on Request Offering page
$(window).load(function() {
if (document.URL.indexOf("ServiceCatalog/RequestOffering") === -1) {
if (!session.user.Security.CreateOnBehalf) return;
}
// Hide create request on behalf of picker by default
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').hide();
// Create toggle and append after the picker
var toggler_CBR = $('<button class="toggler">Switch...</button>');
toggler_CBR.appendTo('label.control-label:contains("' + localization.CreateRequestonbehalfof + '")');
// Set toggle function (Show Hide)
$("#button_CRB").button()
$("button.toggler").click(function() {
$Switch = $(this);
$Switch.toggleClass('off');
if ($Switch.is(".off")) {
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').show();
}
else {
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.two-action-input-group').hide();
}
});
// Change the placeholder text in the picker
$('.control-label:contains("' + localization.CreateRequestonbehalfof + '")').parent().find('.k-input.search-combo').attr("placeholder", "Search for User")
});