How Announcement will be default to ESC Portal if no portal is selected?

Devi12
Giga Guru

Hi all,

I had a requirement that the announcements should default to ESC portal. For this requirement I have written a before insert BR. So whenever a new announcement is created, the Portal will set to ESC Portal. But the issue came in, when a portal is selected other than ESC before saving it is adding both the portals(ESC and the selected one before saving) which should not be the case.

So I tried to put condition in my business rule, but it didn't worked for me. I am attaching screenshots here.

How can I change it to display whenever the Portal is empty?

find_real_file.png

Both portals are populating.

find_real_file.png

Above is the before insert BR I have written, but not working

1 ACCEPTED SOLUTION

Vasantharajan N
Giga Sage
Giga Sage

Please try the below code after making the necessary changes.

    var sp_def_sysId = '81b75d3147032100ba13a5554ee4902b'; //Please update to your Default Service Portal sys_id value

    var gr = new GlideRecord("m2m_announcement_portal");  
	gr.addQuery("announcement",current.sys_id);
    //gr.addQuery('sp_portal', sp_def_sysId);  // If you want to check whether this announcement is already available on your default portal then enable this one.
    gr.query();
    if (!gr.next()) { 
        gr.initialize();
        gr.announcement = current.sys_id;
        gr.sp_portal = sp_def_sysId;
        gr.insert();
    }

Thanks & Regards,
Vasanth

View solution in original post

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Try deleting other portal record from BR before inserting for ESC ? that should work I guess

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

If you don't mind, can you provide the script for the same.

Vasantharajan N
Giga Sage
Giga Sage

Please try the below code after making the necessary changes.

    var sp_def_sysId = '81b75d3147032100ba13a5554ee4902b'; //Please update to your Default Service Portal sys_id value

    var gr = new GlideRecord("m2m_announcement_portal");  
	gr.addQuery("announcement",current.sys_id);
    //gr.addQuery('sp_portal', sp_def_sysId);  // If you want to check whether this announcement is already available on your default portal then enable this one.
    gr.query();
    if (!gr.next()) { 
        gr.initialize();
        gr.announcement = current.sys_id;
        gr.sp_portal = sp_def_sysId;
        gr.insert();
    }

Thanks & Regards,
Vasanth

Thanks for the reply Vasantharajan!

I tried with the script, working fine if I commented 

gr.addQuery('sp_portal', sp_def_sysId);

If I uncommented above it is showing two portals, if I add other than ESC portal.