Setting linked record does not link properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hrdy90
    Junior Member
    • Apr 2021
    • 28

    Setting linked record does not link properly

    I'm using the following formula with "Case" entity and Trigger type: After record saved:
    PHP Code:
    $message = (description);
    
    $apartmentidLine = string\match($message, '/LägenhetsID\: (.*)$/m');
    $apartmentid = string\substring($apartmentidLine, 13);
    
    realEstatePropertyId = $apartmentid; 
    
    A case description might look like this:


    Description:
    Test!

    LägenhetsID: 644a42027d091dd82

    This does add "644a42027d091dd82" in the correct place, but it does not lookup or link correctly. If I update the case manually it does however reapply the link and it works as expected. What am I missing?


    Attached Files
  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    try to also send the name, not only the id

    Comment


    • hrdy90
      hrdy90 commented
      Editing a comment
      But realEstatePropertyId with ID 644a42027d091dd82 already exists with all that information. Clicking the link "644a42027d091dd82" takes me to that object where apartment name and other details already are set.

      And updating the case manually makes the link "644a42027d091dd82" become correct "Ramvägen 8, Stockholm". So it does understand the ID 644a42027d091dd82 correctly - it just does not create the link correctly unless I manually update the case record.

    • Kharg
      Kharg commented
      Editing a comment
      if you check the network tab in developer tools you will see that when you select "Ramvägen 8, Stockholm" the request will both contain the apartment name and the apartment id.

    • hrdy90
      hrdy90 commented
      Editing a comment
      You are very correct! I will set realEstatePropertyName manually for now then. But is there no way to work around this? I.E to make it do the lookup after record is updated?

      Thank you!
  • hrdy90
    Junior Member
    • Apr 2021
    • 28

    #3
    Well, I did as you suggested:
    PHP Code:
    $message = (description);
    
    $addressLine = string\match($message, '/Gatuadress\: (.*)$/m');
    $address = string\substring($addressLine, 12);
    
    $apartmentidLine = string\match($message, '/LägenhetsID\: (.*)$/m');
    $apartmentid = string\substring($apartmentidLine, 13);
    
    realEstatePropertyName = $address;
    realEstatePropertyId = $apartmentid;

    Case description:
    Gatuadress: Ramvägen 8
    Beskrivning av felet:
    Test!

    LägenhetsID: 644a42027d091dd82
    But it is unfortunately still only showing as "644a42027d091dd82" unless i manually click edit followed by save somewhere in the case.

    Comment

Working...