- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2016 09:19 AM
On our incident form we have the company and caller fields:
If a user clicks the reference icon:
And then clicks the new button:
I would like to have the company field auto populated based on the company selected in the incident.
I have considered modifying the onclick of the reference picker so it inserts the sys id of the company into the url of the reference picker popup as a sysparm. Then using a client script on the sys_ref_list view of the user form to retrieve the sys id from the referring url. However, this involves dom manipulation in order to replace the onclick which I would like to avoid. Also we have a number of other similar situations in our system and the same would need to be implemented for all of them.
I was thinking there has to be a simpler way to achieve this but was unable to find a solution online. Does anybody have a better idea?
Thanks,
Matt
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 09:51 AM
Okay so i've implemented this solution in a test system and it seems to be working nicely. I've posted it here for the benefit of others and for some constructive criticism.
1) Set the the the value of "Dependant" in the dictionary record of the user field on the incident form to "company".
2) Create the following client script on the user table:
Type: onLoad
Global: false
View: sys_ref_list
// Set the company from sysparm_dependent of the referrer if it's a new record and the view is sys_ref_list
// author: matt a
function onLoad() {
if (g_form.isNewRecord() && typeof document !== 'undefined' && 'referrer' in document) {
var referrer = document.referrer.toString();
var i = referrer.indexOf('sysparm_dependent=');
if (i !== -1) {
var sysid = referrer.substr(i + 18, 32);
if (/^[a-f0-9]{32}$/i.test(sysid)) {
g_form.setValue('company', sysid);
g_form.setReadOnly('company', true);
}
}
}
}
This should work for any similarly related fields on other tables. I will actually be using this on account and contact tables within our prod instance. The use of the company and user was just an example to illustrate my issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 08:38 AM
Why do they need the reference field to find someone? don't they not just search in the field?
About making a ref qual on the field. sadly that doesn't follow through and becomes a "filter" on all. My guess there is that goes along like a query Business rule.
About modifying the ref picker, be aware thou that I think if you modify this one, it will probably affect every reference field in the system. and then you need to modify the "new" button as well to take the value with it later..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 07:57 AM
Probably not an answer, but a question to drive to an answer maybe. Could you not set a session variable, or use g_scratchpad, and then use an onLoad script for the new user form to populate elements based on that value you stashed in your session variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 11:03 AM
Yes that is a possibility and it would solve the problem without having to resort to DOM manipulation. I've had a little think about how I might do it and it may just be my limited understanding of how to impliment the solution but I have a few issues:
- It would still require a bit of work to impliment it in all the places required. (Though this is probably unavoidable, I was kind of hoping someone would say "oh that's easy just do x").
- I would have to send the selected account back to the server everytime it changes, not a big deal but it would be nice to keep it client side if possible.
- Because of 2 it might be difficult to create a direct link between the page which set the property and the window where the reference will be written. For example if a user opens a new incident form and sets a company this would be sent to the server and set in a session property. If they then quickly open another incident in a new window the company from that incident would then overwrite the property. If then then return to the previous one and try to create a new user the company from the other incident would be retrieved.
I was thinking you could prefix the property name with the incident sys_id to solve issue 3 but I couldn't see a way of retrieving the incident sys_id from the new user form. Also there would still be the potential of getting into a muddle over having the same incident in other tabs or by communication issues with the server (though admittedly these would only be a small chance).
Can you think of a better way to impliment this solution to ensure the property retrieved is the one intended?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 09:14 PM
Hi Matt,
Just curious to know, how are user accounts created in your instance and who has access to create them? Are they created through LDAP import or is there any other integration through which a normal user account is getting created.
As per above requirement any ITIL user could create a new user account altogether. It doesn't sound much robust option to control user creation and manage user accounts in general. Also, it could result in duplicate or incomplete user profiles.
You can restrict the search results by setting up a reference qualifier that would show up related callers based on the selected company. If a user is not found, I'd suggest having a separate process to request user creation. Of course, I'm suggesting this not knowing the exact business requirement that you have. Let someone else provide you a better solution, if you must create new users using this process.
Regards,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 01:23 AM
Actually it's not the user or company tables at all in our system. I just used those as a more general example that would be familiar to more people and hopefully more likely to be answered. We actually have separate account and contact tables for our customers company records and their associated contacts. These are the actual references we have on our incident table. The above was just an example.
We have a number of controls in place to regulate the creation of customer contacts along with support processes to ensure a caller is authorised to speak on behalf of a given company. Also there are already reference qualifiers against the contact field to display only the selected customers contacts (or contacts of their trusted partners).
Actual user accounts can only be created by system administrators and then only after receiving an approved change request
Thanks for your concern though. Hope this clears it up a bit.