The CreatorCon Call for Content is officially open! Get started here.

Redirect user to a different url using Business rule

Alon Grod
Tera Expert

Hi,

Im trying to redirect user using onAfter Business rule but I had no luck, what am I doing wrong?

var gr = new GlideRecord('sys_attachment');
	gr.addEncodedQuery('table_sys_id='+current.getUniqueValue());
	gr.query();
	if(gr.next()){
		gs.log('zhahgaha');
		gs.setRedirect('/sys_attachment.do?sys_id=2522a51393c30210b73aba7efaba105a');
	}
8 REPLIES 8

Can you provide the full script you have now after making the changes?

Can you add a gs.addInfoMessage to check whats going on?

Do you have attachment in the attachment table in that record?

Also can you provide the use case you want to achieve? Non-admin users mayn't have access to the sys_attachment table.


Please mark this response as correct or helpful if it assisted you with your question.

@SanjivMeher 

Im admin. Im getting the log so it means that I have an attachment.

var gr = new GlideRecord('sys_attachment');
    gr.addEncodedQuery('table_sys_id=' + current.getUniqueValue());
    gr.query();
    if (gr.next()) {

		gs.log('zzzzza');
        var url = gs.generateURL('sys_attachment', gr.sys_id);

        gs.setRedirect(url);
    }




Do you have option to use a UI action instead?

Is there a separate button you are clicking other than Save to trigger this?


Please mark this response as correct or helpful if it assisted you with your question.

@SanjivMeher Unfortunately i hvae to use Business Rule. Yes, I just change the state to completed and that is trigger the BR to work.