Announcement

Collapse
No announcement yet.

Creating a new user. Error 403 (Version 7.5.1)

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

  • #16
    Maybe you have default value specified for Contact field in User entity type. Or some code that sets a value.

    Comment


    • #17
      for now:
      1 no formulas
      2 worker processes no
      3 required fields are missing
      4 there are no entries in the logs

      there is a popup error:
      Error 403: Access denied
      Can't relate with non-existing Contact record.​

      in browser console​:
      Server side error 403: Can't relate with non-existing record.
      Failed to load resource: the server responded with a status of 403 ()
      espo.js:12946 CRM/api/v1/User​

      Comment


      • #18
        There must be some relationship user - contact, many-to-many, or one-to-many. Thing is that a non-existent contact ID is passed to the service. Either from the front-end, or in the backend (workflow, formula, etc.). Maybe you have also a link-multiple field for that link, maybe with a default value.

        Also setting printTrace for logger can be helpful https://docs.espocrm.com/administrat...trace-printing

        Comment


        • #19
          there is a link to the relationship user - contact, as described here Multiple Assigned Users

          The Assigned User field is not set as required

          Click image for larger version

Name:	Contacts.png
Views:	408
Size:	25.6 KB
ID:	94080 Click image for larger version

Name:	assignedUsers.png
Views:	376
Size:	39.5 KB
ID:	94081

          Comment


          • yuri
            yuri commented
            Editing a comment
            I was asking about "default value", not "required".

        • #20
          printTrace

          PHP Code:
          [2023-06-19 11:52:03NOTICE: (403Can't relate with non-existing record.; POST /User; line: 56, file: /home/qtoday/q.today/q/CRM/application/Espo/Core/Exceptions/Forbidden.php :: #0 /home/qtoday/q.today/q/CRM/application/Espo/Core/Record/Access/LinkCheck.php(174): Espo\Core\Exceptions\Forbidden::createWithBody('Can't relate wi...''{"messageTransl...'#1 /home/qtoday/q.today/q/CRM/application/Espo/Core/Record/Access/LinkCheck.php(148): Espo\Core\Record\Access\LinkCheck->processLinkedRecordsCheckItem(Object(Espo\Entities\User), Object(Espo\ORM\Defs\RelationDefs), '1') #2 /home/qtoday/q.today/q/CRM/application/Espo/Core/Record/Access/LinkCheck.php(76): Espo\Core\Record\Access\LinkCheck->processLinkMultiple(Object(Espo\Entities\User)) #3 /home/qtoday/q.today/q/CRM/application/Espo/Core/Record/Service.php(667): Espo\Core\Record\Access\LinkCheck->process(Object(Espo\Entities\User)) #4 /home/qtoday/q.today/q/CRM/application/Espo/Services/User.php(155): Espo\Core\Record\Service->create(Object(stdClass), Object(Espo\Core\Record\CreateParams)) #5 /home/qtoday/q.today/q/CRM/application/Espo/Core/Controllers/RecordBase.php(181): Espo\Services\User->create(Object(stdClass), Object(Espo\Core\Record\CreateParams)) #6 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/ControllerActionProcessor.php(87): Espo\Core\Controllers\RecordBase->postActionCreate(Object(Espo\Core\Api\RequestWrapper), Object(Espo\Core\Api\ResponseWrapper)) #7 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/ControllerActionHandler.php(65): Espo\Core\Api\ControllerActionProcessor->process('User', 'create', Object(Espo\Core\Api\RequestWrapper), Object(Espo\Core\Api\ResponseWrapper)) #8 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Espo\Core\Api\ControllerActionHandler->handle(Object(Slim\Psr7\Request)) #9 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/RouteProcessor.php(222): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #10 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/RouteProcessor.php(149): Espo\Core\Api\RouteProcessor->processControllerAction(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\ResponseWrapper)) #11 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/RouteProcessor.php(127): Espo\Core\Api\RouteProcessor->processAfterAuth(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\ResponseWrapper)) #12 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/RouteProcessor.php(78): Espo\Core\Api\RouteProcessor->processInternal(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\RequestWrapper), Object(Espo\Core\Api\ResponseWrapper)) #13 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/Starter.php(109): Espo\Core\Api\RouteProcessor->process(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Slim\Psr7\Response)) #14 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Espo\Core\Api\Starter->Espo\Core\Api\{closure}(Object(Slim\Psr7\Request), Object(Slim\Psr7\Response), Array) #15 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Psr7\Request), Object(Slim\Psr7\Response), Array) #16 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(Slim\Psr7\Request)) #17 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #18 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #19 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run(Object(Slim\Psr7\Request)) #20 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Slim\Routing\RouteRunner->handle(Object(Slim\Psr7\Request)) #21 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner)) #22 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #23 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(Psr\Http\Server\RequestHandlerInterface@anonymous)) #24 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #25 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #26 /home/qtoday/q.today/q/CRM/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(Slim\Psr7\Request)) #27 /home/qtoday/q.today/q/CRM/application/Espo/Core/Api/Starter.php(76): Slim\App->run() #28 /home/qtoday/q.today/q/CRM/application/Espo/Core/ApplicationRunners/Api.php(45): Espo\Core\Api\Starter->start() #29 /home/qtoday/q.today/q/CRM/application/Espo/Core/Application/RunnerRunner.php(84): Espo\Core\ApplicationRunners\Api->run() #30 /home/qtoday/q.today/q/CRM/application/Espo/Core/Application.php(78): Espo\Core\Application\RunnerRunner->run('Espo\\Core\\Appli...', NULL) #31 /home/qtoday/q.today/q/CRM/public/api/v1/index.php(35): Espo\Core\Application->run('Espo\\Core\\Appli...') #32 {main} 
          Attached Files

          Comment


          • item
            item commented
            Editing a comment
            Php version error
            Need php >= 8.1

          • yuri
            yuri commented
            Editing a comment
            Negative .

        • #21
          The problem is that you named the link (with Contact entity type) 'assignedUsers'. 'assigneeContacts' would be more relevant name.

          Comment


          • alexisc
            alexisc commented
            Editing a comment
            You are right, thanks a lot!

        • #22
          alexisc,

          I managed to reproduce your error only when I selected a specific Contact as the default value in the assignedUsers field settings, then deleted this Contact from instance and tried to create a Portal User. EspoCRM, PHP and MySQL versions are the same as yours, so that was not the issue.

          I'll ask you to take a close look at the Detail View of your portal user record. There should be your field called Contacts. Judging by the error and its analysis, this field is filled in automatically. If this field is not on the Detail View (neither on the sidebars, nor in the bottom ones, nowhere), then go to the Layout Manager and drag it to any place. Then you will see that the field is automatically filled.

          There is no other explanation yet.​

          Comment


          • yuri
            yuri commented
            Editing a comment
            The cause of the problem of THIS TOPIC is the link named "assignedUsers" as I mentioned above 2 times. I'm 99% sure and I managed to reproduce. "Do not pre-fill assigned user on record creation" should be unchecked in preferences to be able to reproduce.
            Last edited by yuri; 06-20-2023, 07:59 AM.

          • yuri
            yuri commented
            Editing a comment
            < unfortunately, I still got the error.

            This is an expected behavior, not unfortunately.

          • esforim
            esforim commented
            Editing a comment
            We can't auto-filled (default) when using this, but it should be OK with copy it over using Formula right?

            I usually do a formula like this (example, ignore syntax error)

            ifThen (assignedUser!=null, assigned=record\attribute('parentid','assignedUser )

        • #23
          Many thanks to everyone for the help!
          Sorry for the long reply, I was out of work.

          Problem solved.
          The system automatically associated the new user with a contact - my administrator account.
          This became visible when I added the "Contact" field to the "Layout Manager"
          If "Do not pre-fill assigned user on record creation" is checked, or if the link is removed manually, a new user is created without problems.

          Yury is right, there is a problem with the "assignedUsers" link.
          Click image for larger version

Name:	Contacts.png
Views:	320
Size:	45.3 KB
ID:	94650

          Comment


          • #24
            I can't rename "assignedUsers" link to "assigneeContacts" for example. I can only delete and create a new one.

            how to do it more safely, so as not to lose existing connections?​

            Comment


            • rabii
              rabii commented
              Editing a comment
              safest way is to create the new relationship name it as assigneeContacts then update the data with the links from previous one then you can then it.

            • alexisc
              alexisc commented
              Editing a comment
              I had to delete and recreate in order not to change the link name and save the links in the system, everything worked out, thanks!!!
          Working...
          X