Announcement

Collapse
No announcement yet.

get and set teamsIds and teamsNames in PHP & js

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

  • get and set teamsIds and teamsNames in PHP & js

    Hi,
    How do I get and set the teamsIds and teamsNames for any entity using PHP and js? I have tried $entity->get('teamsIds') & $entity->get('teamsNames') but the result is always null(was trying to implement this in hooks). similarly in js model.set/model.get('teamsIds') result in null or undefined. The response in browser while accessing using the url is working fine with correct result in json format. Can anyone correct me on these lines if I am missing something??

  • #2
    hi
    in php (hook), if field wasn't changed - it isn't loaded ( needs loadLinkMultipleField('teams'))
    Code:
      if (!$entity->has('teamsIds')) {
                    $entity->loadLinkMultipleField('teams');
                }
                $teamsIds = $entity->get('teamsIds');
                $teamsNames = $entity->get('teamsNames');
    in js - in what view you want to read it? print this.model (or model) in console to check attributes

    Comment


    • #3
      Perfect. I was missing "loadLinkMultipleField". Thanks a ton . In js, I was trying to read it in detail view of opportunites and modal view of one of the custom modules we have. I have tried doing console.log of model, rest of the fields are fine except for teamsNames, which I get as undefined.

      Comment

      Working...
      X