Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add Attachment Automatically from Idea to Demand to Story table.

Baker1
Tera Guru

Hi Team,
I need to Add Attachment automatically from idea to demand to story.
can Someone please help me.

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Baker1 

 

These 2 links will be helpful

https://www.servicenow.com/community/developer-forum/retain-attachment-on-idea-record-when-creating-...

https://www.servicenow.com/community/itsm-articles/copying-attachment-from-one-record-to-another-rec...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG 
thank you for quick reply
Code is not working as expected

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

    var dmnd = new GlideRecord('dmn_demand');
    dmnd.addQuery('sys_id', current.task);
    dmnd.query();
    
    while (dmnd.next()){
        var ideaAttach = new GlideRecord('sys_attachment');
        ideaAttach.addQuery('table_sys_id', current.sys_id);
        ideaAttach.query();
        
        while (ideaAttach.next()){
            ideaAttach.table_sys_id = dmnd.sys_id;
            ideaAttach.table_name = 'dmn_demand';
            ideaAttach.update();
        }
    }

})(current, previous);

Sorry mate, I am not strong in coding 😞

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************