Search code examples
grailsgrails-ormgrails-domain-classgrails-controller

access a specific property of domain class in my controller


Hi I have a program where there are two domain classes. One that has different properties of my data objects (e.g. People) and another which is a User domain class which checks the login id and password to see if the user is authorized to make changes to the database. In my "People" domain class I have a property field called "createdID". I want to set the login id of person who created a new entry in the database to this field. I have been able to get the login id of the person from my user controller class to my people controller class but how do I set the createdID field of my people domain class to this value?


Solution

  • def peopleInstance = new People()   
    peopleInstance.createdId = <whatever value you want to set>
    peopleInstance.save()