function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TheLearnerTheLearner 

Restricting the profile not to edit the field

Hi Expers,

There is object called Triio Project (Master) in this object there is field called Type(Type__c) if this Type='Replacement'  then follwing profiles cannot edit the Work Order Number((Works_Order_Number__c) field which is there in the child object called  Triio Work Order(tRIIO_Works_Order__c) either creation or editing time, if they trying to do that error message should display (Work Order Number can't be amended. Please contact your Administrator).
these are the profiles.
Ferns Sub reinstator (UKPN, NG)
H&S Administration
NGA Commercial
NGA Op & MRS Op & PO Approval
NGA Operational
NGA Sub Reinstator
Sub Reinstator (EDF, NG)
tRIIO Commercial
tRIIO Operational
tRIIO Planners/Schedulers
tRIIO POS and Company
tRIIO POS Only
tRIIO Purchasing
tRIIO Sub Reinstator Admin
Raja236Raja236
Hi 

write a validation rule that checks TEXT of (Triio Project.Type__c) = "Replacement",ISCHANGED(tRIIO_Works_Order__c), and User.profilename caontians of all the profile you want.

 
TheLearnerTheLearner
HI Rajashekhar,

Thanks for reply,  could you guide me atleast by taking one profile  please, at the same time i need to show error msg as well when ever these profiles trying to edit ' Work Order Number can't be amended. Please contact your Administrator'
Raja236Raja236
Hi,
 
Provided sample one,you can try to use this way to write a validation rule and coming to error messgae you have an option in validation rule what message to display and where to display
 
IF(AND(ISPICKVAL(Invoice__r.Status__c,"Replacement"),ISCHANGED( Unit_Price__c ), CONTAINS( $Profile.Name , "NGA Commercial")),true,false)

 
TheLearnerTheLearner
Hi Raja,

I wrote below validation its working fine for update, but i need while creating of the Work order number also, could you help me please.

AND (
TEXT( Project__r.Type__c ) = 'Replacement',
ISCHANGED(Works_Order_Number__c),
OR(
$Profile.Name ='Ferns Sub reinstator (UKPN, NG)',
$Profile.Name = 'H&S Administration',
$Profile.Name = 'NGA Commercial',
$Profile.Name = 'NGA Op & MRS Op & PO Approval',
$Profile.Name = 'NGA Operational',
$Profile.Name = 'NGA Sub Reinstator',
$Profile.Name = 'Sub Reinstator (EDF, NG)',
$Profile.Name = 'tRIIO Commercial',
$Profile.Name = 'tRIIO Operational',
$Profile.Name = 'tRIIO Planners/Schedulers',
$Profile.Name = 'tRIIO POS and Company',
$Profile.Name = 'tRIIO POS Only',
$Profile.Name = 'tRIIO Sub Reinstator Admin',
$Profile.Name = 'tRIIO Purchasing'
)
)
Raja236Raja236
Hi, 

Yes, this validation rule won't work while creating since your checking the Works_Order_Number__c is changed, please create a new validation rule as below sample one.
AND (ISNEW(),
TEXT( Project__r.Type__c ) = 'Replacement',
NOT(ISBLANK(Works_Order_Number__c))),
OR(
$Profile.Name ='Ferns Sub reinstator (UKPN, NG)',
$Profile.Name = 'H&S Administration',
$Profile.Name = 'NGA Commercial',
$Profile.Name = 'NGA Op & MRS Op & PO Approval',
$Profile.Name = 'NGA Operational',
$Profile.Name = 'NGA Sub Reinstator',
$Profile.Name = 'Sub Reinstator (EDF, NG)',
$Profile.Name = 'tRIIO Commercial',
$Profile.Name = 'tRIIO Operational',
$Profile.Name = 'tRIIO Planners/Schedulers',
$Profile.Name = 'tRIIO POS and Company',
$Profile.Name = 'tRIIO POS Only',
$Profile.Name = 'tRIIO Sub Reinstator Admin',
$Profile.Name = 'tRIIO Purchasing'
)
)


 
TheLearnerTheLearner
Hi raja,
Above validation is working fine for while creation, after creatign the triio project record, if i try to edit the workorder number edit , its allowing me to save.but we need while creating and updating as well right
Raja236Raja236
Hi 

Please share the your validation rule, i will try to look into it.
TheLearnerTheLearner
Hi Raja,

This is my validaon rule. we need:

1. i need while creating and editing as well, i mean while creating the Projec record with Type='Replacement' and i will create child Work order record and i will give value in the 'Works_Order_Number__c' it need to throw an error.
2. Already existing workorder record  there if i changed Type= 'Replacment' in the parent project record at the time also it need to throw an error , if i  try to update the values in the 'Works_Order_Number__c'.

AND (ISNEW(),

TEXT( Project__r.Type__c ) = 'Replacement',


PRIORVALUE(Works_Order_Number__c)=NULL),


OR(

$Profile.Name ='Ferns Sub reinstator (UKPN, NG)',

$Profile.Name = 'H&S Administration',

$Profile.Name = 'NGA Commercial',

$Profile.Name = 'NGA Op & MRS Op & PO Approval',

$Profile.Name = 'NGA Operational',

$Profile.Name = 'NGA Sub Reinstator',

$Profile.Name = 'Sub Reinstator (EDF, NG)',

$Profile.Name = 'tRIIO Commercial',

$Profile.Name = 'tRIIO Operational',

$Profile.Name = 'tRIIO Planners/Schedulers',

$Profile.Name = 'tRIIO POS and Company',

$Profile.Name = 'tRIIO POS Only',

$Profile.Name = 'tRIIO Sub Reinstator Admin',

$Profile.Name = 'tRIIO Purchasing',

$Profile.Name = 'System Administrator'

)

)
Raja236Raja236
AND (OR(ISNEW(), ISCHANGED(Works_Order_Number__c)),

TEXT( Project__r.Type__c ) = 'Replacement',


(Works_Order_Number__c <> PRIORVALUE(Works_Order_Number__c)),


OR(

$Profile.Name ='Ferns Sub reinstator (UKPN, NG)',

$Profile.Name = 'H&S Administration',

$Profile.Name = 'NGA Commercial',

$Profile.Name = 'NGA Op & MRS Op & PO Approval',

$Profile.Name = 'NGA Operational',

$Profile.Name = 'NGA Sub Reinstator',

$Profile.Name = 'Sub Reinstator (EDF, NG)',

$Profile.Name = 'tRIIO Commercial',

$Profile.Name = 'tRIIO Operational',

$Profile.Name = 'tRIIO Planners/Schedulers',

$Profile.Name = 'tRIIO POS and Company',

$Profile.Name = 'tRIIO POS Only',

$Profile.Name = 'tRIIO Sub Reinstator Admin',

$Profile.Name = 'tRIIO Purchasing',

$Profile.Name = 'System Administrator'

)

)
Hi ,

check the above code, i have written  on the fly in text editor, apologise if there is any syntax error, i hope you can take care  of it

2) write a similar validation rule on parent object.