- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 02:33 AM
Hi,
I have a service catalog form that is used by customers to fulfill change requests on users. In this form, 6 users field (reference) to select the users to apply the change. I wanted to disable the selected user on the first field in the other fields. For example, if Jon Doe is the first selected, he can't be selected on the other fields.
I found removeOption() (out-of-the-box) and disableOption (SN guru) solutions. But it seems to me that it only works on Choice lists and not on reference fields.
Is someone able to confirm this and may be help me in another solution ?
Best regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 11:23 AM
Hi,
I finally have something right. I was not aware of reference qual so for all of you in my case, that's what I've done :
- On the reference variable (for memory, my variables are named user1, user2,... user6)
- set Use reference qualifier: Advanced
- set Reference qual: javascript:Except_these_users()
- Create a script include
- name : Except_these_users
- Script (and only the following) :
function Except_these_users() {
//used for SIT-10 and SIT-07
var j = 1;
var anwser;
var user_selected;
answer = "sys_id!="
while(j<7) {
user_selected = current.variables['user'+ j];
if (j<6) {
if (user_selected != '') {
answer += user_selected +'^sys_id!=';
//gs.log('Il y a ' + current.variables['user'+ j] + ' dans la liste ' + 'user'+j);
}
}
else {
if (user_selected != '') {
answer += user_selected;
//gs.log('Il y a ' + current.variables['user'+ j] + ' dans la liste ' + 'user'+j);
}
}
j++;
}
//gs.log('answer : ' + answer);
return answer;
}
And it's working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 02:47 AM
you can user reference qualifier and pass on the variable value in it for validations.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 02:52 AM
something like this
if there are two fields,
field1 and field2
then in field2 reference qual you can add below filter script, if is about user table then
javascript:'user_name!='+current.variables.field1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 05:46 AM
Hello Anurag,
Well my reference fields are named : user1, user2, ... user6
When I use an advanced qual on user2, the selected user1 is still in the list :
javascript:'user_name!='+current.variables.user1
Probably, it's because it won't dynamically change when a user is set in user1.
So I put it in catalog script but it doesn't work either. Can you help me ?
i a number between 1 and 6 (for useri : user1, user2, etc.).
j = 1; |
var selected_user = g_form.getValue('user'+i);
while(j<7) {
if (j!=i) { | ||
//g_form.removeOption('user'+j, selected_user); | ||
//disableOption('user'+j, newValue); | ||
g_form.variables('user'+j).reference_qual = "javascript:'user_name!='+current.variables.user"+ i | ||
alert('Retire ' + selected_user + ' de la liste ' + 'user'+j); | ||
} | ||
j++; |
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2016 11:23 AM
Hi,
I finally have something right. I was not aware of reference qual so for all of you in my case, that's what I've done :
- On the reference variable (for memory, my variables are named user1, user2,... user6)
- set Use reference qualifier: Advanced
- set Reference qual: javascript:Except_these_users()
- Create a script include
- name : Except_these_users
- Script (and only the following) :
function Except_these_users() {
//used for SIT-10 and SIT-07
var j = 1;
var anwser;
var user_selected;
answer = "sys_id!="
while(j<7) {
user_selected = current.variables['user'+ j];
if (j<6) {
if (user_selected != '') {
answer += user_selected +'^sys_id!=';
//gs.log('Il y a ' + current.variables['user'+ j] + ' dans la liste ' + 'user'+j);
}
}
else {
if (user_selected != '') {
answer += user_selected;
//gs.log('Il y a ' + current.variables['user'+ j] + ' dans la liste ' + 'user'+j);
}
}
j++;
}
//gs.log('answer : ' + answer);
return answer;
}
And it's working.