Announcement

Collapse
No announcement yet.

Missing parent ID during record creation in relationship panel

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

  • Missing parent ID during record creation in relationship panel

    I have a relationship defined like this:

    Click image for larger version  Name:	image.png Views:	0 Size:	19.8 KB ID:	83404

    In an authorization, I want to relate a new service by clicking the + in the relationship panel:

    Click image for larger version  Name:	image.png Views:	0 Size:	577 Bytes ID:	83405



    The flyout appears and the link to the authorization is present as expected:

    Click image for larger version  Name:	image.png Views:	0 Size:	15.8 KB ID:	83406


    The request to the server includes the authorization ID as well:

    Code:
    {
       "authorizationId":"625c8623ad61fa0c7",
       "authorizationName":"Non-Billable",
       "teamsIds":[
          "619cdff8812c61705",
          "60e77591063fffa91"
       ],
       "teamsNames":{
          "619cdff8812c61705":"Administrative",
          "60e77591063fffa91":"Owners"
       },
       "unitsUsed":0,
       "unitsRemaining":0,
       "daysTotal":0,
       "daysTranspired":0,
       "daysRemaining":0,
       "unitsProjectedBalance":0,
       "name":"Direct Therapy",
       "cPTCodesIds":[
          "6245811185913e578"
       ],
       "cPTCodesNames":{
          "6245811185913e578":"97151"
       },
       "description":null,
       "unitsMaxPerWeek":null,
       "unitsMaxPerMonth":null,
       "unitsApproved":5,
       "assignedUserName":null,
       "assignedUserId":null
    }​


    However, the entity data in the hook does not have the authorization ID and the new service does not relate to the authorization:

    PHP Code:
      public function afterSave(Entity $service, array $options = array()) {
        
    $GLOBALS["log"]->debug("afterSave",[$service->toArray()]);
        
    $this->calculateMetrics($service);
      }

      public function 
    beforeSave(Entity $service, array $options = array()) {
        
    $GLOBALS["log"]->debug("beforeSave",[$service->toArray()]);
      }

      public function 
    beforeRelate(Entity $service, array $options = array()) {
        
    $GLOBALS["log"]->debug("beforeRelate",[$service->toArray()]);
      }

      public function 
    afterRelate(Entity $service, array $options = array()) {
        
    $GLOBALS["log"]->debug("afterRelate",[$service->toArray()]);
      }
    ​ 
    Code:
    [2022-09-23 15:41:34] DEBUG: beforeSave  [{"id":"632dd3ae79952e303","name":"Direct Therapy","deleted":false,"description":null,"createdAt":"2022-09-23 15:41:34","modifiedAt":"2022-09-23 15:41:34","unitsApproved":5,"unitsUsed":0,"unitsRemaining":0,"unitsMaxPerWeek":null,"daysTotal":0,"daysTranspired":0,"daysRemaining":0,"unitsProjectedBalance":0,"unitsMaxPerMonth":null,"createdById":"60e77309b0a75b5b2","assignedUserId":null,"assignedUserName":null,"teamsIds":["60e77591063fffa91"],"teamsNames":{"stdClass":{"60e77591063fffa91":"Owners"}},"cPTCodesIds":["6245811185913e578"],"cPTCodesNames":{"stdClass":{"6245811185913e578":"97151"}}}] []
    [2022-09-23 15:41:34] DEBUG: afterRelate [{"id":"632dd3ae79952e303","name":"Direct Therapy","deleted":false,"description":null,"createdAt":"2022-09-23 15:41:34","modifiedAt":"2022-09-23 15:41:34","unitsApproved":5,"unitsUsed":0,"unitsRemaining":0,"unitsMaxPerWeek":null,"daysTotal":0,"daysTranspired":0,"daysRemaining":0,"unitsProjectedBalance":0,"unitsMaxPerMonth":null,"createdById":"60e77309b0a75b5b2","assignedUserId":null,"assignedUserName":null,"teamsIds":["60e77591063fffa91"],"teamsNames":{"stdClass":{"60e77591063fffa91":"Owners"}},"cPTCodesIds":["6245811185913e578"],"cPTCodesNames":{"stdClass":{"6245811185913e578":"97151"}}}] []
    [2022-09-23 15:41:34] DEBUG: afterRelate [{"id":"632dd3ae79952e303","name":"Direct Therapy","deleted":false,"description":null,"createdAt":"2022-09-23 15:41:34","modifiedAt":"2022-09-23 15:41:34","unitsApproved":5,"unitsUsed":0,"unitsRemaining":0,"unitsMaxPerWeek":null,"daysTotal":0,"daysTranspired":0,"daysRemaining":0,"unitsProjectedBalance":0,"unitsMaxPerMonth":null,"createdById":"60e77309b0a75b5b2","assignedUserId":null,"assignedUserName":null,"teamsIds":["60e77591063fffa91"],"teamsNames":{"stdClass":{"60e77591063fffa91":"Owners"}},"cPTCodesIds":["6245811185913e578"],"cPTCodesNames":{"stdClass":{"6245811185913e578":"97151"}}}] []
    [2022-09-23 15:41:34] DEBUG: afterSave   [{"id":"632dd3ae79952e303","name":"Direct Therapy","deleted":false,"description":null,"createdAt":"2022-09-23 15:41:34","modifiedAt":"2022-09-23 15:41:34","unitsApproved":5,"unitsUsed":0,"unitsRemaining":0,"unitsMaxPerWeek":null,"daysTotal":0,"daysTranspired":0,"daysRemaining":0,"unitsProjectedBalance":0,"unitsMaxPerMonth":null,"createdById":"60e77309b0a75b5b2","assignedUserId":null,"assignedUserName":null,"teamsIds":["60e77591063fffa91"],"teamsNames":{"stdClass":{"60e77591063fffa91":"Owners"}},"cPTCodesIds":["6245811185913e578"],"cPTCodesNames":{"stdClass":{"6245811185913e578":"97151"}}}] []​

    ​The new service record exists, but it must be manually linked to the authorization using the select option in the relationship panel:

    Click image for larger version  Name:	image.png Views:	0 Size:	20.3 KB ID:	83407


    This issue does not occur with every relationship panel. I tried several others and they work as expected. I have not changed the clientDef or entityDef files for the Authorization or Service entities. Any ideas would be appreciated.​

  • #2
    Hi,



    the declaration of function is not compliant i think

    Comment


    • #3
      That's fair, but the ID should be present in the beforeSave and afterSave functions as well, which are defined correctly. I'm seeing this work as expected in many other entities in my system, so I'm not sure what could cause the parent to disappear.

      Comment


      • item
        item commented
        Editing a comment
        maybe in entityDefs, maybe missing something.

    • #4
      I solved this problem by removing the relationship between the tables and then recreating it. I don't know why that worked, but it did.

      Comment

      Working...
      X