How To Prevent View Inheritance

Issue: For one of my projects, we had different views on the tasks than we did on the parent case. However, if you click on a task with a view called ‘Task view’, when you clicked the parent, the parent would inherit this view (even though we didn’t want it to). It would even ignore view rules set up specifically for that record. This was the same with all reference fields.

Solving this turned out to be a one line piece of code.

The reason is, when clicking the parent link (or any other reference value), it performs a function called ‘checkSave’ and then a function called ‘checkSaveID’ (you can read these functons by clicking ctrl+alt+shift+J and then typing ‘alert(checkSave);’)

checkSaveID then adds the view paremeter to the link that it uses to view the parent. The view is stored in a hidden field on the form called ‘sysparm_view’ (you can check this by loading up the javascript editor again and typing ‘alert($(‘sysparm_view’).value;)

So the solution to ensuring the parent case does not inherit the task’s view, is by clearing out the value in this field which can be accomplished using the following on load client script:

function onLoad() {
 nbsp; gel('sysparm_view').value = '';

Of course you can make this more complicated/logical by checking the value of gel(‘sysparm_view’) and see if it is a view you want to override or not. But I’ll leave that to you as that depends on your actual implementation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s