Formula Help of if then

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nishan Perera
    Active Community Member
    • Jan 2019
    • 348

    Formula Help of if then

    Hello,

    I'm trying to figure out below formula to work. Sum related formula is working perfectly. And with that I want to update the Sum Related record created on current month. So I tried with below formula and it didn't work.

    Code:
    ifThen (
    supply_dispatch.createdAt== datetime\month(),
    totalIssue = entity\sumRelated('supplyDispatchs', 'supply_dispatch.dispatchingUnits')
    );
    Appreciate your support to sort this matter.
    Cheers!
    Nishan.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1602

    #2
    Hi, I think the second argument is not right.
    Without knowing your relationship name I guess:

    - supplyDispatchs is the relationship Link name
    - in the second argument you only should insert the related field name, not the relationship name again, so in my opinion dispatchingUnits would be enough.

    Comment

    • Maximus
      Senior Member
      • Nov 2018
      • 2731

      #3
      Hi,
      try this:
      Code:
      ifThen (
          datetime\month(supply_dispatch.createdAt) == datetime\month(datetime\today()) ,
          totalIssue = entity\sumRelated('supplyDispatchs', 'supply_dispatch.dispatchingUnits')
      );

      Comment

      • Nishan Perera
        Active Community Member
        • Jan 2019
        • 348

        #4
        Maximus Thank you for the reply. I tried given code and it doesn't work. But below code worked with datetime\today()

        Code:
        ifThen ([INDENT]datetime\today('supply_dispatch.createdAt') == datetime\today(datetime\today()) ,[/INDENT][INDENT]totalIssue = entity\sumRelated('supplyDispatchs', 'supply_dispatch.dispatchingUnits')[/INDENT]
         );

        What I want with this is to update totalIssue if supply_dispatch.createdAt on current month.
        Cheers!
        Nishan.

        Comment

        • Nishan Perera
          Active Community Member
          • Jan 2019
          • 348

          #5
          I've solved the formula, this works perfectly. Thank you for your great support Maximus as always.

          Code:
          ifThen ([INDENT]datetime\month('supply_dispatch.createdAt') == datetime\month('datetime\today()'),[/INDENT][INDENT]totalIssue = entity\sumRelated('supplyDispatchs', 'supply_dispatch.dispatchingUnits')[/INDENT]
           
          
           );
          Cheers!
          Nishan.

          Comment

          Working...