Menu

Unknown attribute location_id from class Team

Chris H.
2023-06-16
2023-06-17
  • Chris H.

    Chris H. - 2023-06-16

    Hey folks,

    we create our users and persons via an extra php script and that worked fine so far.
    But now the person can no longer be found, only the user is accessible.

    I have checked our script and everything works as before.
    When troubleshooting I found the error from the title when trying to search for the person.
    Possibly there is a problem with location_id but it is correct and I could not find anything regarding the class Team in DB or through the interface.

    Hope someone can help.
    Thanks!

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-06-16

    So it creates a user, but no person?

    Since you're using it through a PHP script: are you using the API? Might be good to show the output you get after making the API call.

     
    • Chris H.

      Chris H. - 2023-06-16

      Hello Jeffrey,

      and thanks for the fast reply.

      The script creates both, but only the user could be found in web interface. (without Given Name and Surname)

      Here is an extract from our script:

      // person
              $result = $mysqli->query("INSERT INTO `person`(`first_name`, `employee_number`) VALUES ('$vorname', '$SAM')");
              $person_id = $mysqli->insert_id;
      
          // contact
              $result = $mysqli->query("INSERT INTO `contact`(`name`, `status`, `org_id`, `email`, `notify`, `finalclass`, `obsolescence_date`) VALUES (".
              "'$nachname', 'active', '$orgID', '$email', 'yes', 'Person', NULL)");
              $contact_id = $mysqli->insert_id;
      
          // priv_user
              $result = $mysqli->query("INSERT INTO `priv_user`(`contactid`, `login`, `language`, `status`, `finalclass`) VALUES (".
              "'$contact_id','$SAM','DE DE','enabled','UserExternal')");
              $user_id = $mysqli->insert_id;
      
          // priv_urp_userprofile
              $result = $mysqli->query("INSERT INTO `priv_urp_userprofile`(`userid`, `profileid`) VALUES ($user_id, 2)");
      

      The script was created by a former employee, it is our own API, in a way.

      I didn't know that an account creation is also possible via an API. If it can be integrated into our PowerShell, I might change over.

      Thank you!

       

      Last edit: Chris H. 2023-06-16
      • Jeffrey Bostoen

        Jeffrey Bostoen - 2023-06-16

        It's direct database manipulation, which is not recommended.

        In fact, the order is wrong. "Person" is a subclass of "contact". So "Contact" should be created before person. Both a person and a team are contacts. The table of contacts might therefore have IDs which are only present in the "person" or "team" tables.

         
        • Chris H.

          Chris H. - 2023-06-16

          Hello Jeffrey,

          it has worked very well so far and I'm afraid it can't be changed so fast.
          But I will have a look at the official REST API.
          Is there any documentation for it?

          As for the error, do you think it comes from the wrong order?
          Is there anything I can do to fix this so that the error "Unknown attribute location_id from class Team" no longer occurs?

          So persons and teams are both contracts, but in the DB it says person with the user and not team.

          Thank you very much!

           
          • Chris H.

            Chris H. - 2023-06-16

            Anyway, it was a good hint I now realised that the ID was not the same because of a previously created team, which is why the reference to a team in the error.

            I would still appreciate information about the official API so that I can switch to it.

            Thank you very much!

             
          • Jeffrey Bostoen

            Jeffrey Bostoen - 2023-06-17

            It may be a result of the wrong order.

            https://www.itophub.io/wiki/page?id=latest:advancedtopics:rest_json

            You'll still need to make sure the order of execution is correct. But if you create a "person" with the API, it will automatically create the record in the "contact" table as well.

             

            Last edit: Jeffrey Bostoen 2023-06-17

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.