error : getFieldValue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abidoss
    Senior Member
    • Mar 2023
    • 230

    error : getFieldValue

    Hello
    Could someone help me? I have these errors in the log, and I thank you in advance

    [2023-10-09 00:12:25] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
    [2023-10-09 00:12:25] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].
  • lazovic
    Super Moderator
    • Jan 2022
    • 810

    #2
    Hi abidoss,

    Please show screenshots of your workflows, where you work with Contact and Mois entities inside actions, so that we can reproduce this error and solve it together.

    Also, please specify which versions of EspoCRM and Advanced Pack extension you are using.
    Last edited by lazovic; 10-09-2023, 08:57 AM.

    Comment

    • abidoss
      Senior Member
      • Mar 2023
      • 230

      #3

      I have nearly 25 connections between the "Contact" and "Mois" entities.
      I'm using version 7.5.6 and pack 3.10.


      Comment

      • abidoss
        Senior Member
        • Mar 2023
        • 230

        #4


        But I have two files in custom\Espo\Custom\Jobs, which could cause an issue.

        PHP Code:
        
        <?php
        namespace Espo\Custom\Jobs;
        
        use Espo\Core\ORM\EntityManager;
        use Espo\Core\Job\JobDataLess;
        use Carbon\Carbon;
        class UpdateContactsIC implements JobDataLess
        {
            public function __construct(private EntityManager $entityManager){}
            public function run(): void
            {
                $collection = $this->entityManager
                    ->getRDBRepository('Contact')
                    ->find();
        
                foreach ($collection as $contact) {
                    $disponibilit = $contact->get('disponibilit');
                    $contact->set('ic', $this->diffInWorkingDays(carbon::today(), carbon::make($disponibilit)));
                    $this->entityManager->saveEntity($contact);
                }
            }
            protected function diffInWorkingDays($dt1, $dt2)
            {
                return $dt1->diffInDaysFiltered(function(Carbon $date) {
                        return !$date->isWeekend();
                    }, $dt2, false);
            }
        }
        ​and

        PHP Code:
        
        <?php
        
        namespace Espo\Custom\Jobs;
        
        use Carbon\Carbon;
        use Espo\Core\Job\JobDataLess;
        use Espo\Core\ORM\EntityManager;
        
        class UpdateContactsStatus implements JobDataLess
        {
            public function __construct(private EntityManager $entityManager){}
        
            public function run(): void
            {
                $collectionMois = $this->entityManager
                    ->getRDBRepository('Mois')
                    ->find();
        
                foreach ($collectionMois as $contact) {
                    $dateStart = $contact->get('dateStart');
                    $dateEnd = $contact->get('dateEnd');
                    $status = $this->getStatus(Carbon::today(), Carbon::make($dateStart), Carbon::make($dateEnd));
                    $contact->set('status', $status);
                    $this->entityManager->saveEntity($contact);
                }
                
                $collectionAnne = $this->entityManager
                    ->getRDBRepository('Anne')
                    ->find();
        
                foreach ($collectionAnne as $contact) {
                    $dateStart = $contact->get('dateStart');
                    $dateEnd = $contact->get('dateEnd');
                    $status = $this->getStatus(Carbon::today(), Carbon::make($dateStart), Carbon::make($dateEnd));
                    $contact->set('status', $status);
                    $this->entityManager->saveEntity($contact);
                }
            }
        
            protected function getStatus($dt1, $dt2, $dt3 = null)
            {
                if ($dt2 !== null && $dt3 !== null) {
                    return 'Held';
                }
        
                $diffInDays = $dt1->diffInDays($dt2, false);
        
                if ($diffInDays < -7) {
                    return 'Retard';
                } elseif ($diffInDays < 0) {
                    return 'Not Held';
                } else {
                    return 'Planned';
                }
            }
        }
        

        Comment

        • lazovic
          Super Moderator
          • Jan 2022
          • 810

          #5
          abidoss,

          Go to the list of Workflows, click on the three dots in the right corner next to the “+ Create Rule” button and go to the Workflows Log page. Find, based on the time indicated in the error log (2023-10-09 00:12:25, keep in mind that the UTC time is indicated in the log), the workflow that reproduces the error.

          In general, such an error approximately indicates that another entity was simply not related to some entity while the workflow was running, and it cannot update (fill in) non-existent fields.​

          Comment

          • abidoss
            Senior Member
            • Mar 2023
            • 230

            #6
            I have no trace in the log, which confirms that the issue is related to these two jobs



            custom\Espo\Custom\Jobs\UpdateContactsStatus.php
            custom\Espo\Custom\Jobs\UpdateContactsIC.php

            But I don't know exactly where the issue is.

            Comment

            • abidoss
              Senior Member
              • Mar 2023
              • 230

              #7
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:03:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:04:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:04:56] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:05:01] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.status] entity [Mois] has unsupported instance [NULL].
              [2023-10-19 00:05:01] ERROR: Workflow [Utils::getFieldValue]: The related field [contact.ic] entity [Mois] has unsupported instance [NULL].

              Comment


              • rabii
                rabii commented
                Editing a comment
                it is a workflow issue and has nothing to do with the job. you have a workflow that is trying to get the status from the contact related to entity Mois but the contact is null. Review your workflow for entity Mois and add condition to make sure that the contact is not null.

              • abidoss
                abidoss commented
                Editing a comment
                Alright, thank you Rabii. I need to stop all the workflows of this entity to find out which one is causing the issue.

              • rabii
                rabii commented
                Editing a comment
                This is probably a workflow which the target entity is Mois.
            Working...