Announcement

Collapse
No announcement yet.

Update task-dateEndDate if an entity's createdat is >= to task.dateEndDate

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

  • Update task-dateEndDate if an entity's createdat is >= to task.dateEndDate

    Hi,
    So I linked(one is to one) task to an entity and would like to change status to completed or move duedate if I created an entity. Formula is below
    ifThen(createdAt>=task.dateEndDate, task.dateEndDate=datetime\addDays(task.dateEndDate , 1));

    I also did the formula below but still didn't work
    ifThen(createdAt>=task.dateEndDate, task.status="Completed");
    Last edited by ciryaj; 10-23-2023, 03:03 PM.

  • #2
    Hi,

    It's not possible to update related entities this way. You can use record\update formula function.

    I also recommend to use if statement instead of ifThen function.

    Comment


    • #3
      Originally posted by yuri View Post
      Hi,

      It's not possible to update related entities this way. You can use record\update formula function.

      I also recommend to use if statement instead of ifThen function.
      Hi, thank you for your help as always but I can't make it to work.

      If I use code below

      if (createdAt>=task.dateEndDate)
      {
      record\update('Task','64bf750d77909f54d','dateEndD ate',datetime\addDays(dateEndDate, 1))
      }

      It says syntax error and if I use code below nothing happens.​

      ifThen(createdAt>=task.dateEndDate,
      record\update('Task', '64bf750d77909f54d','dateEndDate', datetime\addDays(dateEndDate, 1)
      ));

      Comment


      • #4
        Problem is that you are trying to use the dateTime function on non existing field datetime\addDays(dateEndDate, 1), dateEndDate is a field of task and you can't access it this way may be you could try as datetime\addDays(task.dateEndDate, 1), anyway for better readability you can try this code below:

        PHP Code:
        if (taskId) {
            
        $dateEndDate record\attribute('Task'taskId'dateEndDate');
            
            if (
        createdAt $dateEndDate) {
                
        record\update('Task'taskId'dateEndDate'datetime\addDays($dateEndDate 1));
            }
        }
        ​ 
        Last edited by rabii; 10-24-2023, 07:50 AM.
        Rabii
        Web Dev

        Comment


        • #5
          Maybe you get the error because you missed semicolon ; in the end of statement.

          Consider also using dateEnd instead of dateEndDate. The latter is available only if your task does not have a time part.

          Comment


          • #6
            I already have a solution but I will try these and see if it is better. What I did is just to update a field in task that will trigger a change of dateEndDate. So basically all the formula is in task to change the dateEndDate ahaha it worked though but I think it is not a good solution. This community is really the best.

            Comment

            Working...
            X