7 Replies · Latest reply on Oct 16, 2017 3:59 AM by Jayantha Rao

    I want to insert record to 'cmdb_rel_ci' table through Business rule

      I have written before business rule.

       

      var gr=new GlideRecord('x_42426_automation_automation_rules');

      gr.addQuery('automation_category','calculate_relationship');

      gr.orderBy('order');

      gr.query();

      gs.addInfoMessage('test 1');

        while(gr.next())

        {

        var attribute=gr.getValue('target_attribute');

        var val=gr.getValue('target_value');

        var query = gr.getValue('query_string');

         gs.addInfoMessage('test 2');

      var match=GlideFilter.checkRecord(current,query);

       

         if (match)

         {

         var childT=current.name;

         var manages='Managed by';

      gs.addInfoMessage(val);

         setRelationshipValues(val, childT, manages);

         }

      }

       

      function setRelationshipValues(parent, child, relationshipType) {  

      gs.addInfoMessage(parent);

      gs.addInfoMessage(child);

      gs.addInfoMessage(relationshipType);

        var rel_ci = new GlideRecord("cmdb_rel_ci");  

        rel_ci.initialize();  

        rel_ci.parent = parent;   

        rel_ci.child = child;   

        rel_ci.type = relationshipType;  

        if(rel_ci.parent!=rel_ci.child)

        {

        rel_ci.insert(); }

      }

       

      its inserting empty record in 'cmdb_rel_ci' table. Could anyone please help on this.