Help with Workflows/Business Rules

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • animax
    Senior Member
    • Jun 2018
    • 155

    #16
    There is an Error 500 in Formular Sandbox

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #17
      try this without using list :

      PHP Code:
      $count = entity\countRelated('posteingang');
      
      // get list of all the related entities Posteingang given the count above and also specifying only one specific stage
      $posteingang = record\findRelatedMany('Domizilservice', id, 'posteingang', $count, 'createdAt', 'desc', 'status=', 'erledigt (Kunde Inaktiv)');
      
      $i = 0;
      
      // loop through collection and update their status
      while(
      $i < array\length($posteingang),
      (
      record\update('Posteingang', array\at($posteingang, $i), 'status', 'erfasst');
      $i = $i + 1;
      )
      Rabii
      Web Dev

      Comment

      • animax
        Senior Member
        • Jun 2018
        • 155

        #18
        I checked everything, the error was actually in the designation. "posteingangs" is correct! But I don't see that name in the entity. Here the plural means "Posteingang"

        The following code now works perfectly!

        Code:
        $count = entity\countRelated('posteingangs');
        
        // get list of all the related entities Posteingang given the count above and also specifying only one specific stage
        $posteingangs = record\findRelatedMany('Domizilservice', id, 'posteingangs', $count, 'createdAt', 'desc', 'status=', list('erledigt (Kunde Inaktiv)'));
        
        $i = 0;
        
        // loop through collection and update their status
        while(
        $i < array\length($posteingangs),
        (
        record\update('Posteingang', array\at($posteingangs, $i), 'status', 'erfasst');
        $i = $i + 1;
        )
        );​

        Thank you very much for your effort. Thanks alot!​

        Comment


        • rabii
          rabii commented
          Editing a comment
          i knew it, usually a one to many relationship are plural, if you go to administration / entity manager / Domizilservice / relationship (you can check the correct relationship name there).

          I am glad it is working now.
          you are very welcome
      Working...