You need to sign in to do that
Don't have an account?
TheLearner
Not to update or edit the field in the while creating and updating the field
Hi experts,
When ever the the project type is =' Replacement' it should not allow profiles either creation or updattion child record field called Works_Order_Number__c, it working fine for the creation not on updation. could anyone help me please.
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',
$Profile.Name = 'System Administrator'
)
)
When ever the the project type is =' Replacement' it should not allow profiles either creation or updattion child record field called Works_Order_Number__c, it working fine for the creation not on updation. could anyone help me please.
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',
$Profile.Name = 'System Administrator'
)
)
All Answers
Remove this and try.
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'.
anyone help me pleease
Its working fanastic thanks alot for ur quick reply
i have one requriment, could you help me please.
i need to do some amendments in my trigger, when ever Defect_on_Hold__c checkbox is checked, i need to change this Activity_Status__c field value from "INTrR" to "HOLD". im not getting where and how exactly i need to amendments,Could anyone help please.
trigger tRIIO_Calc_Activity_Status_And_Fields on tRIIO_Activity__c (before update, before insert) {
//To calculate Reinstatement Status
if(!Test.isRunningTest())
if(Trigger.isUpdate){
Boolean isActivityWithoutOM = false;
Boolean isAnyOMWithoutFM = false;
Boolean doesAnyFMHaveInterimDate = false;
String Status = '';
Integer countInterimDate = 0;
for(tRIIO_Reinstatement_FM__c fm:[SELECT Id, Interim_Date__c FROM tRIIO_Reinstatement_FM__c WHERE Activity__c =: trigger.new[0].id]){
if(fm.Interim_Date__c != null)
countInterimDate++;
}
List<tRIIO_Reinstatement_OM__c> OM = [select id, name,FM__c from tRIIO_Reinstatement_OM__c where Activity__c =: trigger.new[0].id ];
Boolean isNotWithOutOM = false;
Boolean isAnyOMWOFM = false;
Boolean doesNiFMHaveInterimDate = false;
String NGA_Work_Status_Text = '';
if (OM.size()==0) {
isActivityWithoutOM = true;
} else {
//Loop for all OMs and if any OM is without FM then set the flag
for(tRIIO_Reinstatement_OM__c a : OM) {
if (a.FM__c!=true) {
isAnyOMWithoutFM = true;
}
}
if (countInterimDate > 0) {
doesAnyFMHaveInterimDate = true;
}
}
//if there are no Original Measures for Notice set Status to 'Schld'
if (isActivityWithoutOM == true) {
Status = 'Schld';
} else {
//if any original measures is without a final measures set status to 'InPrg'
if (IsAnyOMWithoutFM == true) {
Status = 'InPrg';
} else {
//if any final measures have an interim date set status to 'InPrg' else set to 'IntReinst'
if (DoesAnyFMHaveInterimDate == true) {
Status = 'IntrC';
} else {
Status = 'PermC';
}
}
}
trigger.new[0].Status__c = Status;
}
//To calculate Activity Status
if(Trigger.isInsert || Trigger.isUpdate){
String ActivityStatus = '';
tRIIO_Activity__c [] ActivityNew;
ActivityNew = trigger.new;
for( tRIIO_Activity__c Nots : ActivityNew){
if(Nots.Activity_Status__c != 'IntrR(S)'){
Nots.Clk_Int_Perm__c = false;
}
}
Profile p = [SELECT Id,Name FROM profile WHERE id=:Userinfo.getProfileId()];
String currentProfile = p.Name;
String readOnlyProfiles = 'NG Read-Only';//Add other read-only profiles here seperated by ,
if (readOnlyProfiles.indexOf(currentProfile) > -1){
ActivityNew[0].addError('You do not have sufficient privilages to add or modify records.');
}
for(tRIIO_Activity__c activity : ActivityNew){
if ((activity.Activity_Status__c != 'IntrR(S)')&&(activity.Activity_Status__c != 'Cancelled') ) {
if (activity.Abandoned__c == true){
if(activity.Hit_Int_Perm__c == true){
ActivityStatus = 'Awaiting Notice';
} else{
ActivityStatus = 'Abandoned';
}
}
else{
//If Works Close Date AND Registration Date exists AND Reinstatement Status = "Schld" then "Nil Reinstatement"
if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'Schld'))
ActivityStatus = 'Nil Reinstatement';
//If Works Close Date AND Registration Date exists AND Reinstatement Status = "PermC" then "PermR"
else if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'PermC'))
ActivityStatus = 'PermR';
//If Works Close Date exists AND Registration Date does not exist AND Reinstatement Status = "PermC" then "PermC"
else if ((activity.Works_Close__c != null) && (activity.Registration__c == null) && (activity.Status__c == 'PermC'))
ActivityStatus = 'PermC';
//If Works Close Date AND Registration Date exists AND Reinstatement Status = "IntrC" then "IntrR"
else if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'IntrC'))
ActivityStatus = 'IntrR';
//If Works Close Date exists AND Registration Date does not exist AND Reinstatement Status = "IntrC" then "IntrC"
else if ((activity.Works_Close__c != null) && (activity.Registration__c == null) && (activity.Status__c == 'IntrC'))
ActivityStatus = 'IntrC';
//If Actual Start Date exists then "InPrg
else if ((activity.Actual_Start__c != null))
ActivityStatus = 'InPrg';
//If Works Start Date exists then "Notice Raised"
else if ((activity.Works_End_Date__c != null))
ActivityStatus = 'Notice Raised';
else
ActivityStatus = 'Awaiting Notice';
}
activity.Activity_Status__c = ActivityStatus;
//If this is a new record then default reinstatement status to 'Schld'
if(Trigger.isInsert)
activity.Status__c = 'Schld';
}
//when Reinstatement status changes to a status that is not 'PermC'or 'IntrC'then deattach Activity from closure report
//so that it can can be added to next batch
if ((activity.Status__c != 'PermC')&&(activity.Status__c != 'IntrC')){
activity.Closure_Report__c = null;
}
if(Trigger.isInsert){
Map<Id,Double> mapCounts = tRIIO_QuotationAttachment.ValidateNotice(ActivityNew);
for(tRIIO_Activity__c activity_Quotation: Trigger.new){
if(activity_Quotation.Works_Order__c != null){
if(mapCounts.get(activity_Quotation.Works_Order__c) != null && mapCounts.get(activity_Quotation.Works_Order__c) != 0.0){
activity_Quotation.addError('Notice already generated for this Quotation');
}
}
}
}
}
}
}