+ Start a Discussion
divya1234divya1234 

How to fetch the profile id from model user

Hi All,

I have a trigger on provisiong object to create a user record when provising record gets created on page layout i have a field called model if user select model user it should assign the profile from user  and assign it to new user  ...but it not assigning and thoughing a error that profiel id is empty when i am trying to to with query  it is working perfectly but i dont want to user querry here . how can i avoid query here
User M=[Select id,Name,ProfileId, from User where Id =: PR.Model__c];
PR.ProfileId = M.Profile Id///THis is working 

i am trying to avoid a query and writing like this

  usr.ProfileId = PR.User__r.ProfileId; // it is not fetching the profile and thoughing and error.

 
Raj VakatiRaj Vakati
Use this code
 
Model__c model = [ Select User__r.ProfileId from Model__c where id =:m.Id ] ; 
  usr.ProfileId = model.ProfileId; // it is not fetching the profile and thoughing and error.