2 Replies · Latest reply on Oct 19, 2017 5:38 AM by Chanikya Karthik

    how to get  " Used Amount"  field of sum of amount value into Another table " Remaing Amount" field

      Hi Everyone ,

       

      I want to display ''Used amount''  total sum value in another table of   "Reaming Amount" field

      Table : incident

      fields: used amount

       

       

       

       

      if you see " Used Amount" value  first 8000$ +5000$+3000$ total=16000$ so total amount should display in portfolio table- Reaming amount field

       

       

      Table: Portfolio

      filed: Reaming amount

       

        • Re: how to get  " Used Amount"  field of sum of amount value into Another table " Remaing Amount" field
          Martin

          Hi Chanikya,

           

          you would need a script which sums up all the used amounts of the relavant incidents (related to that portfolio record) and write that value into the remaining amount field. That could be a business rule which runs on update & insert for new incidents or a scheduled script running periodically.

           

          var my_sum=0;

          var gr = new GlideRecord('incident');.

          gr.addQuery(); // put whatever conditions you need - i.e. incidents related to a certain portfoliio record or in some state

          gr.query();

           

          while (gr.next()) {

          my_sum+=gr.used_amount;

          }

           

          Than write my_sum into the field in the portfolio record.
          At least that`s how i would do it or similar.

           

          Cheers!

           

          Martin

          Please mark this post Helpful, Like it, or mark as the Correct Answer where applicable. Thanks!