- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 09:37 PM
Hi,
On project form, we have change request related list, which allows the user to create a new change request. My requirement is to make that new form open in a custom view when i try to create the change using new button as shown below.
I wrote a view rule on change request with below condition which opens the already created project related changes in the new view but I need the new form to be opened in the custom view when i try to create from the related list of project
I also tried using an on load client script as shown below but that applies to all changes. I need to restrict that client script to work on new forms that i try to create using related list on project which i am unable to because the record is not yet created and so unable to differentiate between the project change records and other changes.
Please let me know how this can be achieved as i have an immediate requirement
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 04:01 AM
Hi Sreedhar,
Change of view tries to update the record that is why you are getting that error.
Use the below mentioned code in your onLoad client script. In the example I have assumend incident table to be the table available in the related list:-
if(window.location.search.indexOf('sys_is_related_list=true')>1 && g_form.isNewRecord()&& window.location.search.indexOf("sysparm_view=your_view_name")<1){
window.location="https://your_instance.service-now.com/incident.do?sys_id=-1&sysparm_view=your_view_name"
}
Please mark Helpful if this solves your issue.
Thanks,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2017 04:53 AM
Please let us know how the above can be achieved. Immediate help is much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2017 08:14 AM
Hi Gayatri,
For this first of all you need to check if a form is being opened by clicking on the new button from related list. If you look closely the URL of new form opened using NEW button available in related list then you will see url contains parameter 'sys_is_related_list=true'.
Now to achieve your requirement write a onLoad client script check the URL for the presence of 'sys_is_related_list=true' and if found true then set the required view.
if(window.location.search.indexOf('sys_is_related_list=true')>1)
Please mark helpful if this solves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2017 08:14 PM
Hi Kamlesh,
I have a similar requirement but when I use switchview in my client script, the form reloads and gives me record not found error.
Please let me know how this can be avoided
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 04:01 AM
Hi Sreedhar,
Change of view tries to update the record that is why you are getting that error.
Use the below mentioned code in your onLoad client script. In the example I have assumend incident table to be the table available in the related list:-
if(window.location.search.indexOf('sys_is_related_list=true')>1 && g_form.isNewRecord()&& window.location.search.indexOf("sysparm_view=your_view_name")<1){
window.location="https://your_instance.service-now.com/incident.do?sys_id=-1&sysparm_view=your_view_name"
}
Please mark Helpful if this solves your issue.
Thanks,
Kamlesh