Announcement

Collapse
No announcement yet.

ifThen formula inside of record\create formula

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ifThen formula inside of record\create formula

    Hey everyone. Not sure anyone can assist me on this. I need to use a ifThen formula within the record\create. Below is what Im using. Anyone see where Im messing up on this? I've messed with this for hours but can't seem to have any luck.

    $invoiceId=record\create(
    'Invoice',
    'dateInvoiced', datetime\now(),
    'billToId', ownerId,
    'accountId', id,
    'preDiscountedAmount', fireDueCost,
    'grandTotalAmount', fireDueCost,

    'dueDate',ifThen(
    client.fireDuesNetTerms == '14 Days',
    entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 14))
    );



    ifThen(
    client.fireDuesNetTerms == '30 Days',
    entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 30))
    );



    ifThen(
    client.fireDuesNetTerms == '60 Days',
    entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 60))
    );


    ifThen(
    client.fireDuesNetTerms == '90 Days',
    entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 90))
    );,
    );


  • #2
    lol,
    if you can't do it in .. make it outside
    put your result to variable $dueDate..
    ifThen(
    client.fireDuesNetTerms == '90 Days',
    $dueDate = datetime\addDays(dateInvoiced, 90))
    );

    and then use it in your record/create( 'dueDate', $dueDate)

    ​​​​​​​

    Comment


    • #3
      Thanks for the response. I haven't used Variables yet but if I understood you correctly it would be this?

      Comment


      • item
        item commented
        Editing a comment
        put the word/text and not print screen !

    • #4
      $duedate=ifThen(
      client.fireDuesNetTerms == '14 Days',
      entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 14))
      );

      ifThen(
      client.fireDuesNetTerms == '30 Days',
      entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 30))
      );

      ifThen(
      client.fireDuesNetTerms == '60 Days',
      entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 60))
      );

      ifThen(
      client.fireDuesNetTerms == '90 Days',
      entity\setAttribute('dueDate', datetime\addDays(dateInvoiced, 90))
      );

      $invoiceId=record\create(
      'Invoice',
      'dateInvoiced', datetime\now(),
      'billToId', ownerId,
      'accountId', id,
      'preDiscountedAmount', fireDueCost,
      'grandTotalAmount', fireDueCost,
      'dueDate', $duedate,
      );

      Comment


      • #5
        $dueDate = '2022-12-25'; // put a default value or you are the only who know
        ifThen(
        client.fireDuesNetTerms == '14 Days',
        $dueDate = datetime\addDays(dateInvoiced, 14)
        );

        ifThen(
        client.fireDuesNetTerms == '30 Days',
        $dueDate= datetime\addDays(dateInvoiced, 30)
        );

        ifThen(
        client.fireDuesNetTerms == '60 Days',
        $dueDate= datetime\addDays(dateInvoiced, 60)
        );

        ifThen(
        client.fireDuesNetTerms == '90 Days',
        $dueDate= datetime\addDays(dateInvoiced, 90)
        );

        and in entity\create('dueDate', $dueDate)

        Comment


        • #6
          Its not working

          $duedate=
          ifThen(
          client.fireDuesNetTerms == '14 Days',
          $duedate=datetime\addDays(datetime\now(), 14))
          );

          ifThen(
          client.fireDuesNetTerms == '30 Days',
          $duedate=datetime\addDays(datetime\now(), 30))
          );

          ifThen(
          client.fireDuesNetTerms == '60 Days',
          $duedate=datetime\addDays(datetime\now(), 60))
          );

          ifThen(
          client.fireDuesNetTerms == '90 Days',
          $duedate=datetime\addDays(datetime\now(), 90))
          );


          $invoiceId=record\create(
          'Invoice',
          'dateInvoiced', datetime\now(),
          'billToId', ownerId,
          'accountId', id,
          'preDiscountedAmount', fireDueCost,
          'grandTotalAmount', fireDueCost,
          'dueDate', $duedate,
          );

          Comment


          • #7
            Originally posted by dodom2 View Post
            Its not working

            $duedate=
            ifThen(
            client.fireDuesNetTerms == '14 Days',
            $duedate=datetime\addDays(datetime\now(), 14))
            );
            ifThen don't return anythink !!!

            your line is bad..must be simply so

            ifThen(
            client.fireDuesNetTerms == '14 Days',
            $duedate=datetime\addDays(datetime\now(), 14))
            );

            And follow camelCase ! (it's just for respect espoCRM)

            duedate => dueDate


            Comment


            • #8
              Thank you for help still. You still taught me the purpose of the variable and so I appreciate you.

              Comment

              Working...
              X