You need to sign in to do that
Don't have an account?
priya bhawna shetty
apex class related to user and profile
hello guys
hope all are doing well.pls help with this.
pls check my "if" condition that,how do i write a if codition in such a way that if the current users profile is 'System Administrator' populate phone field and if the profile is 'Standard Platform user' populate the Revenue field.
Error: Compile Error: Expression cannot be assigned at line -1 column -1
public class runasdemo2{
user u1=[select user.profile.name, user.Username from user where profile.name='Standard Platform User' and user.username='aasalesforce.consultant11@gmail.com'];
user u2=[select user.profile.name, user.Username from user where profile.name='System Administrator' and user.username='salesforce.learner999@gmail.com'];
{
if(u1.contains(profile.name='Standard Platform User'))
{
account a1=new account();
a1.name='testaccount';
a1.annualrevenue=12345;
insert a1;
}else
{
account b1=new account();
b1.name='salesforce';
b1.phone=2345;
insert b1;
}
}
}
hope all are doing well.pls help with this.
pls check my "if" condition that,how do i write a if codition in such a way that if the current users profile is 'System Administrator' populate phone field and if the profile is 'Standard Platform user' populate the Revenue field.
Error: Compile Error: Expression cannot be assigned at line -1 column -1
public class runasdemo2{
user u1=[select user.profile.name, user.Username from user where profile.name='Standard Platform User' and user.username='aasalesforce.consultant11@gmail.com'];
user u2=[select user.profile.name, user.Username from user where profile.name='System Administrator' and user.username='salesforce.learner999@gmail.com'];
{
if(u1.contains(profile.name='Standard Platform User'))
{
account a1=new account();
a1.name='testaccount';
a1.annualrevenue=12345;
insert a1;
}else
{
account b1=new account();
b1.name='salesforce';
b1.phone=2345;
insert b1;
}
}
}
user u1=[select user.profile.name, user.Username from user where profile.name='Standard Platform User' and user.username='aasalesforce.consultant11@gmail.com' LIMIT 1];
and your if clause is slightly off. You want:
if(u1.profile.name.contains('Standard Platform User'))