Hi,
I need some help with a before save script:
Setting:
- an entity named person
- an entity named occasion
- a n:n relation between person and occasion
- some data saved in middle table ('CPersonOccasion') of n:n relation. Here: field 'contacedBy'
- a n:1 relation from person to person
- in entity person, fields personParent (n:1) and occasion (n:n)
I try to save the contents of field person.personParent into a field CPersonOccasion.contactedBy in middle table, using formula in before save script.
Script is before save in entity person:
$poId = entity\attribute('id');
$poContact = entity\attribute('personParentName');
$poRelId = record\findOne('CPersonOccasion', 'createdAt', 'desc', 'personId=', $poId);
record\update('CPersonOccasion', $poRelId, 'contactedBy', $poContact);
If I change either personParent or occasion fields and save, nothing happens. BUT: after having saved the person record, immediately I put the very same script into formula sandbox and execute. And, TADAA - works perfectly!
Seems, the script only regards saved data. As there is no after save script - how can I solve this?
​Regards
I need some help with a before save script:
Setting:
- an entity named person
- an entity named occasion
- a n:n relation between person and occasion
- some data saved in middle table ('CPersonOccasion') of n:n relation. Here: field 'contacedBy'
- a n:1 relation from person to person
- in entity person, fields personParent (n:1) and occasion (n:n)
I try to save the contents of field person.personParent into a field CPersonOccasion.contactedBy in middle table, using formula in before save script.
Script is before save in entity person:
$poId = entity\attribute('id');
$poContact = entity\attribute('personParentName');
$poRelId = record\findOne('CPersonOccasion', 'createdAt', 'desc', 'personId=', $poId);
record\update('CPersonOccasion', $poRelId, 'contactedBy', $poContact);
If I change either personParent or occasion fields and save, nothing happens. BUT: after having saved the person record, immediately I put the very same script into formula sandbox and execute. And, TADAA - works perfectly!
Seems, the script only regards saved data. As there is no after save script - how can I solve this?
​Regards