Create new record with specific view on UI Action?

ericeger
Tera Guru

Hello all,

I have created a new table that is on a related list and when it comes to creating new records on the related list, I woulld like to be able to do it two ways.   One would be for a user to click on 'New' and go to the Default view.   Another would be to click on a UI Action and have it go to the form with another view.   I have tried creating the UI Action with a redirect to the table using 'action.setRedirectURL('table.do?sys_id=-1&sysparm_view=new_view') and it gives me an error of 'No records selected'.  

I've looked on the forums and found suggestions when it came to switching views on already created records, but this would be for going to a brand new record with a forced view.   Is there another way for me to do this? Thanks!

-Eric

10 REPLIES 10

i think you need to add in spsparm_view_forced=true to your argument, so:



var uri = action.getGlideURI();


var collectionID = uri.get('sysparm_collectionID');


action.setRedirectURL('table.do?sys_id=-1&sysparm_view=my_new_view&sysparm_view_forced=true&sysparm_query=incident%3D' + collectionID);