How to set the default value for form section in an announcement form?

Devi12
Giga Guru

Hi,

I have requirement that an announcement record should have default portal selected when it is loaded. As it is a section tab I don't know how to configure it. Can any one help me on this?

Attached is the screenshot.

1 ACCEPTED SOLUTION

Hello,

Create script like below, it should work, Its working for me

(function executeRule(current, previous /*null when async*/) {

    var gr = new GlideRecord('m2m_announcement_portal');
    gr.initialize();
    gr.announcement = current.sys_id;
    gr.sp_portal = '81b75d3147032100ba13a5554ee4902b';
    gr.insert();

})(current, previous);

 

 

Please Mark ✅ Correct/helpful, if applicable, Thanks!! 
Regards
Sulabh Garg 

Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

View solution in original post

5 REPLIES 5

Sulabh Garg
Mega Sage
Mega Sage

Hi Devi,

There is a table "m2m_announcement_portal" which stores the relationship between Announcement record and the portal.

You may plan to write a BR/script on "Insert" of Announcement record that will insert a new record in the "m2m_announcement_portal" table with default portal.

Hope it helps!!

 

Please Mark ✅ Correct/helpful, if applicable, Thanks!! 
Regards
Sulabh Garg 

Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

I tried, but not able o get the backend value for portal. I have created a before insert BR:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var gr = new GlideRecord('m2m_announcement_portal');
    gr.initialize();

    gr.name = "Test";

    gr.portals = '52fa79f8e763320075c2a117c2f6a991';

})(current, previous);

above is the script I have written. I am not sure how can I update "Portal" field.

Hello,

Create script like below, it should work, Its working for me

(function executeRule(current, previous /*null when async*/) {

    var gr = new GlideRecord('m2m_announcement_portal');
    gr.initialize();
    gr.announcement = current.sys_id;
    gr.sp_portal = '81b75d3147032100ba13a5554ee4902b';
    gr.insert();

})(current, previous);

 

 

Please Mark ✅ Correct/helpful, if applicable, Thanks!! 
Regards
Sulabh Garg 

Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

Thanks for the reply Sulabh Garg!