Syntax Error with While

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ciryaj
    Member
    • Mar 2018
    • 50

    #1

    Syntax Error with While

    Syntax error. Attribute name "Completed") { while($i contains not allowed characters.....
    Code is below:
    Code:
    $i=0;
    if(status=="Completed")
    {
       while($i<array\length(cellphoneIds))
       {
        record\update('Cellphone',
        array\at(cellphonIds, $i),
        'assignment', assignedEmployee);
       }
     $i=$i+1;
    }
  • victor
    Active Community Member
    • Aug 2022
    • 1239

    #2
    ciryaj,

    Please describe in more detail what you are trying to do. At first glance there are two problems:

    1. There is a difference between cellphoneIds and cellphonIds -- the letter "e" is missing.
    2. "$i = $i + 1" should be inside a while.

    Comment

    • ciryaj
      Member
      • Mar 2018
      • 50

      #3
      Originally posted by victor
      ciryaj,

      Please describe in more detail what you are trying to do. At first glance there are two problems:

      1. There is a difference between cellphoneIds and cellphonIds -- the letter "e" is missing.
      2. "$i = $i + 1" should be inside a while.
      Just saw that the install is lower than 7.4 that's why it did not work.
      Tried this but still did not work.
      while($i<array\length(cellphoneIds),
      record\update('cellphoneIds',
      array\at(cellphoneIds, $i),
      'assignment', assignedEmployee)
      $i=$i+1;
      );

      Comment

      • robin
        Junior Member
        • Aug 2025
        • 19

        #4
        i suspect that the record\update call is wrong:
        record\update('cellphoneIds', array\at(cellphoneIds, $i), 'assignment', assignedEmployee)

        The first param should be the EntityType. I dont think your entity type is "cellphoneIds". Its Probably "Cellphones" or more likeley "CCellphones", since i suspect its a custom entity (altough there might be a prebuild entity called "Cellphones" in some extensions, I'm not to sure. Just check in your entity manager what the entity is called)

        second: i suspect you want to relate a cellphone entity with a user (assignedEmployee)?
        If you want to relate, you need to use record\relate function instead of trying to set a link field via record\update.

        also, there is a semicolon missing behind your record\update call

        Hope that helps!

        Comment

        • ciryaj
          Member
          • Mar 2018
          • 50

          #5
          I found my error, it is the ";" right after the record update ")"

          while(array\length(PhoneIds)>0 && status=="Completed",
          record\update('Phone',
          array\at(PhoneIds, $i),
          'assignment', assignedEmployee);
          $i=$i+1;
          );


          what this does is if transaction is over and the record have phones assigned to it. Assigned user to the Phones will be updated based on assigned user in the transaction

          Comment

          Working...