get an object in groovy postcreate script

This topic has 4 replies, 3 voices, and was last updated 5 years, 11 months ago by marco3575.

  • Author
    Posts
  • #13788
     marco3575
    Participant

    hi,
    i have a recon which create objects /managed/person

    In the managed.json, i have :

    “name” : “person”,
    “comment” : “entite regroupant les personnes”,
    “postCreate” : {
    “type” : “groovy”,
    “file” : “groovyscript/person/postCreatePerson”
    },

    I have 100 persons in my source and i see them in my log.
    And i can see that for each person i pass in the postCreatePerson.groovy script.

    My question is : how can i get the current object person in my postCreatePerson.groovy ?

    thanks and sorry for my english

    #13789
     ssripathy
    Participant

    You can do var curPerson = openidm.read(‘managed/person/’ + source._id);

    You would then be able to manipulate the properties or attributes within that curPerson object. Is that what you are looking for?

    #13790
     marco3575
    Participant

    i’ve tried this but i have an error “no such object source” or something like that.
    in a “onCreate” script. I have a source object and a target object.
    but in a postCreate i have it seems that i have no source object. so i don’t know how to get my current object :(

    #13794
     Jake Feasel
    Moderator

    See https://forgerock.org/openidm/doc/bootstrap/integrators-guide/#script-triggers-managed.json

    In “onCreate” for managed objects, the binding you need is “newObject”.

    #13811
     marco3575
    Participant

    my person object is in “object”
    i can directly get object._id, object.name

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?