Dynamic Table in Reference Field in Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 10:29 AM
Hi,
Here is a bit of background information of what we are trying to achieve. I created a record producer which will create a Project once it is submitted. The catalog form contains many fields so I created a custom formatter on the project table in order for the variable editor to show. Everything is working quite well until I noticed the Catalog Client Script and Catalog UI Policies are not running.
From what I read, there is no way to run Catalog Client Script and Catalog UI Policies out side of the RITM and Catalog Task table. Here is the reason why i need the scripts to run on project table. We have a "Client Type" field on the catalog form. It contains the values "Employee" and 'Vendor". Then there is a Reference field right next to it. Depends on the value selected in Client Type, "Emplyee" will show all the records from the sys_user table. Vendor will show records from the vendor table. I am struggling to find the best way to achieve this. The biggest challenge is that I have rouougly 10 sets of combo like this one on the catalog form. I don't mind creating the UI policies for the catalog form, but I don't want to create another set of the same UI policies on the Project table for the reason I mentioned in the first paragraph.
I have tried to few ways but none is an ideal solution. Here is what I tried and why they failed:
- Hacked the table value in Reference Field using client script. I was able to do it. The table changes dynamically but after the table is changed and a value is selected. I cannot see the value in the reference field in the variable editor in the Project atable because it is still using the original table for the reference field.
- Tried to create user and vendor reference field and use UI policies to show and hide them based on the Client Type. It failed because UI Policies don't run on Project table.
- Use method #1, but once the value is selected from the reference field, the name will be entered in a plain textbox and the reference field is hidden. The problem with it is that if the user wants to change to another user of the same Client Type, there is no way to achieve it because the reference field is now hidden.
I apologize for the long description of my problem and it can't be pretty confusing. For those of you who understand my problem, please let me know if you have better solution to my problem.
Thanks,
Sam
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:05 AM
If it were me, I would create a script include that would handle the reference qualifier logic. Pass in current to the script include and get the Client Type value from that. This approach is then re-usable for both the catalog item and on the project table, and allows for a single place to make updates/adding conditions.
Catalog UI Policies only run on catalog items; UI policies can also run on tables but they need to be configured separately. It sounds like you'll need to create separate UI policies on the table if there's a requirement for that (try to minimize use of client scripts to avoid performance impacts). Another option would be to create separate views and view rules to change the view based on certain values. Using this approach, you could have an "employee" view and a "vendor" view, and based on the value in the client type field, force one to be used.
I hope this is helpful and I didn't completely misunderstand your requirements, if anything is unclear I'll try my best to explain further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:39 AM
Hi,
Thanks for the reply. Reference qualifier is not the only thing i need to change dynamically. I need to be able to change the Reference value as well (see attached image below). As far as I know, there is no way to do it through any scripting (well, i did it through Catalog Client Script, the selected value just not showing in Variable Editor in Project). If you know of a way, I would love to hear it
The Views will probably won't work too because i have a few sets of these reference fields on the form. So i will have many combinations. Views could be difficult to manage.
Speaking of Views, we did think about using Database View to combine both User and Vendor table. We can then just use the Database View for the reference field. What do you think of that? Is it possible?
Thanks!
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 12:29 PM
Thanks for the clarification. I'm not aware of any way to change the Reference table value in a user friendly way (technically, you could have an onChange script that would call a script include that would change the reference table, but that would require having to refresh the page).
Would it be possible, given your requirements, to have 2 separate reference fields and then a UI policy to show the correct one based on what is selected in the Client Type field?
I haven't had a need to use Database views yet, so I can't comment on that approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 12:38 PM
Yes. creating two reference fields was my first approach. It works beautifully on the catalog form but then I noticed the Catalog UI Policies wouldn't run under the Project table (it shows both reference fields). Out of the box, Catalog UI Policies only run for RITM and CTASK. I created a new formatter in the Project table to show the variable editor on the Project form, but default, variable editor is not available for Project table. And this custom formatter won't include Catalog Client Script and Catalog UI Policies. AFAIK, there is no way around it and there is were I struggle i am hoping there are other effective alternatives
I hope that makes sense
Sam