-
ChatterFeed
-
0Best Answers
-
3Likes Received
-
0Likes Given
-
73Questions
-
129Replies
Providing space in excel file
Hi Experts,
I am rendering visualforce page as Excel file, i need to provide sapce between two lines , i tried with  , some other tags and css its not wokring at all, could anyone tell me how to do that.
<tr>
<td><b>Display requried</b>
diplay while records (Please choose one of the field )</td></tr>
i want to display like this could anyone help me please
I am rendering visualforce page as Excel file, i need to provide sapce between two lines , i tried with  , some other tags and css its not wokring at all, could anyone tell me how to do that.
<tr>
<td><b>Display requried</b>
diplay while records (Please choose one of the field )</td></tr>
i want to display like this could anyone help me please
- TheLearner
- January 19, 2016
- Like
- 0
Making proper alignment in the pdf-- urgent
Hi Experts,
Im showing picklist values as checkboxes in the pdf page, but im not getting how to make alignment , could anyone help me please in this. Im providing the code where we are using to populate.
I need in this format: values are big so in case its coming next line it has to be below of the value only.
this is my vf code:
<tr>
<td class="value" colspan="10">
<!-- CH01.Start -->
<apex:variable var="i" value="{!0}"/>
<apex:repeat value="{!P2}" var="P">
<apex:variable var="i" value="{!i+1}"/>
<apex:image value="{!If(P.check == true,$Resource.Checked,$Resource.UnChecked)}"/>
<apex:outputLabel value="{!P.val}"/>
<apex:outputLabel rendered="{!IF(i==3,(IF(MOD(i,3)=0,true,false)),false)}" ><br/>
</apex:outputLabel> <apex:outputLabel rendered="{!IF(i>4,(IF(MOD(i,2)=1,true,false)),false)}" ><br/>
</apex:outputLabel>
</apex:repeat>
<!-- CH01.END -->
</td>
</tr>
controller :
public List<picklist> P2 { get; set; }
Schema.DescribeFieldResult fieldResult1 = Non_Compliance__c.Reason_for_Charge__c.getDescribe();
list<schema.picklistentry> values1 = fieldResult1.getPickListValues();
for (Schema.PicklistEntry PL2 : values1)
{
String s = PL2.getValue();
if(NC.Reason_for_Charge__c != null && NC.Reason_for_Charge__c.ContainsIgnoreCase(s)){
P2.add(new picklist(s,true));
}
else{
P2.add(new picklist(s,false));
}
}
}
Im showing picklist values as checkboxes in the pdf page, but im not getting how to make alignment , could anyone help me please in this. Im providing the code where we are using to populate.
I need in this format: values are big so in case its coming next line it has to be below of the value only.
this is my vf code:
<tr>
<td class="value" colspan="10">
<!-- CH01.Start -->
<apex:variable var="i" value="{!0}"/>
<apex:repeat value="{!P2}" var="P">
<apex:variable var="i" value="{!i+1}"/>
<apex:image value="{!If(P.check == true,$Resource.Checked,$Resource.UnChecked)}"/>
<apex:outputLabel value="{!P.val}"/>
<apex:outputLabel rendered="{!IF(i==3,(IF(MOD(i,3)=0,true,false)),false)}" ><br/>
</apex:outputLabel> <apex:outputLabel rendered="{!IF(i>4,(IF(MOD(i,2)=1,true,false)),false)}" ><br/>
</apex:outputLabel>
</apex:repeat>
<!-- CH01.END -->
</td>
</tr>
controller :
public List<picklist> P2 { get; set; }
Schema.DescribeFieldResult fieldResult1 = Non_Compliance__c.Reason_for_Charge__c.getDescribe();
list<schema.picklistentry> values1 = fieldResult1.getPickListValues();
for (Schema.PicklistEntry PL2 : values1)
{
String s = PL2.getValue();
if(NC.Reason_for_Charge__c != null && NC.Reason_for_Charge__c.ContainsIgnoreCase(s)){
P2.add(new picklist(s,true));
}
else{
P2.add(new picklist(s,false));
}
}
}
- TheLearner
- January 08, 2016
- Like
- 0
How to display multipicklist values as checkboxes in pdf
Hi Experts,
I have mulitpicklist field called REASON_FOR_CHARGE__c it contains values almost 14 values those very lengthy so while creating the record if i select the value in the record it need to show in the pdf as ticked as checkbox, for checkboxes images we stored static resoures ($Resource.Checked,$Resource.UnChecked)
, using those checkboxes i need to display and those values need to be show proper alignment in the pdf page,could anyone help me please.
I have mulitpicklist field called REASON_FOR_CHARGE__c it contains values almost 14 values those very lengthy so while creating the record if i select the value in the record it need to show in the pdf as ticked as checkbox, for checkboxes images we stored static resoures ($Resource.Checked,$Resource.UnChecked)
, using those checkboxes i need to display and those values need to be show proper alignment in the pdf page,could anyone help me please.
- TheLearner
- January 08, 2016
- Like
- 0
Removing comma while displaying the record
Hi Experts,
I have requirement i have two fields called Street(acitvity__r.street__c) and Town(acitvity__r.Town__c) which are formula fields, so while displaying the record, if i didnt enter the value in the Town field, comma should not display in the record. could anyone tell me how to do that.
This is my visual force line
<td class="value" colspan="6"><b>Works Location/Address:</b> {!Non_Compliance__c.Street__c} {!Non_Compliance__c.Town__c}</td>
I have requirement i have two fields called Street(acitvity__r.street__c) and Town(acitvity__r.Town__c) which are formula fields, so while displaying the record, if i didnt enter the value in the Town field, comma should not display in the record. could anyone tell me how to do that.
This is my visual force line
<td class="value" colspan="6"><b>Works Location/Address:</b> {!Non_Compliance__c.Street__c} {!Non_Compliance__c.Town__c}</td>
- TheLearner
- January 07, 2016
- Like
- 0
improving the code coverage
HI Experts,
Could anyone improve the code coverage of this class, i mentioned the lines with @ which are not covering.
Could anyone improve the code coverage of this class, i mentioned the lines with @ which are not covering.
public with sharing class WPD_Schedule_4Controller { List<WPD_Condition__c> conditionList = new List<WPD_Condition__c>(); List<WPD_Co_Ordinate__c> coOrdinateList = new List<WPD_Co_Ordinate__c>(); List<WPD_Purchase_Order_Line_Item__c> coPOList = new List<WPD_Purchase_Order_Line_Item__c>(); public WPD_Projects__c Proj; public WPD_Reinstatement__c Work; public WPD_Co_Ordinate__c coOrdinate; public WPD_Purchase_Orders__c poLineItems; public WPD_Post_Code__c postCodeRec; public boolean modulePresent = false; public WPD_Reinstatement__c getWork(){ if (Work==null){ Work= new WPD_Reinstatement__c(); } return Work; } public WPD_Projects__c getProject() { if (Proj==null){ Proj = new WPD_Projects__c(); } return Proj; } public List<WPD_Condition__c> getArrCondition() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (conditionList.size()==0) { for (integer i=0; i<=12; i++) { conditionList.add(new WPD_Condition__c()); } } return conditionList; } public List<WPD_Co_Ordinate__c> getArrCoordinate() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coOrdinateList.size()==0) { for (integer i=1; i<=6; i++) { coOrdinateList.add(new WPD_Co_Ordinate__c()); } } return coOrdinateList; } public List<WPD_Purchase_Order_Line_Item__c> getArrPurchaseOrder() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coPOList.size()==0) { for (integer i=1; i<=20; i++)//CH03 { coPOList.add(new WPD_Purchase_Order_Line_Item__c()); } } return coPOList; } public PageReference save() { //Create savepoint Savepoint sp; List<WPD_Projects__c> WPDProj = [select Id, Name from WPD_Projects__c where Name =:Proj.Name]; //CH04.Start Date estimatePlanDate = Date.newInstance(2014,10,31); System.debug('estimatePlanDate = '+estimatePlanDate); List<WPD_Contract__c> wpdContracts; if(Proj.Estimated_Project_Start_Date__c != null && Proj.Work_Type__c != null) wpdContracts = new List<WPD_Contract__c>([SELECT Id,Name,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (:Proj.Work_Type__c) AND End_Date__c >=: Proj.Estimated_Project_Start_Date__c order by End_Date__c ASC limit 1 ]);//CH05 else wpdContracts = new List<WPD_Contract__c>(); System.debug((Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)+','+wpdContracts.isEmpty()); //CH04.End if(WPDProj.size() > 0) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You can not save as this would create a duplicate record with Work Instruction field value [' + proj.Name + '].'); ApexPages.addMessage(msg); return NULL; } //CH02.Start else if((Proj.Work_Type__c == 'Planned' || Proj.Work_Type__c == 'Planned GSOS') && (Proj.Dig_Start_Date__c == null || Proj.Dig_End_Date__c == null)){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dig Start Date and Dig End Date are mandatory if work type is Planned or Planned GSOS'); ApexPages.addMessage(msg); return NULL; }//CH02.End //CH04.Start else if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate >= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty() && wpdContracts.size() > 1 ){ @@@@@@@@@@@----Not covering.start---@@@@@@@@@@@@@@@@@@ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Combination of Work Type and Estimated Start date does not match one individual current Contract Number record'); ApexPages.addMessage(msg); return NULL; @@@@@@@@@@--Not covering.End---@@@@@@@@@@@@@@@@@@@ }else if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate && wpdContracts.isEmpty()){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'No Contract Number found with Work Type and End Date > Estimated Project Start Date.'); ApexPages.addMessage(msg); return NULL; }else{//CH04.End try{ sp = Database.setSavepoint(); if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate <= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty()){ Proj.Contract__c = wpdContracts.get(0).id; } Proj.Date_Received__c = Date.today(); insert Proj; work.WPD_Projects__c = Proj.Id; work.Works_Start_Date__c = work.Estimated_Start__c; work.Works_End_Date__c = work.Estimated_End__c; insert work; //Save Co-ordinate data for(integer i=0; i<6; i++){ if(coOrdinateList[i].Easting__c!=null || coOrdinateList[i].Northing__c!=null){ @@@@@@@--Notcovering.start---@@@@@@@@@@@@@@@@@@@@@@ coOrdinateList[i].Work__c = Work.Id; if(i==0){ work.Eastings_Start__c=coOrdinateList[i].Easting__c; work.Northings_Start__c=coOrdinateList[i].Northing__c; }else if(i==1){ work.Eastings_End__c=coOrdinateList[i].Easting__c; work.Northings_End__c=coOrdinateList[i].Northing__c; } } } insert coOrdinateList; update work; for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { modulePresent=true; } } if(modulePresent){ //Save Purchase Order poLineItems = new WPD_Purchase_Orders__c(); poLineItems.WPD_Projects__c = Proj.Id; poLineItems.Purchase_Order_No__c = Proj.Name; poLineItems.Date_Received__c = Date.today(); insert poLineItems; //Save Purchase Order Line Item records for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { coPOList[i].PO_Number__c = poLineItems.Id; //coPOList[i].Ordered_Rate__c = coPOList[i].Module__r.Rate__c; //Populate Ordered Rate with Rate from Module object //CH02 commented this line ///coPOList[i].Category__c = 'Not Required'; //Default Category to ‘Not Required’ ///coPOList[i].Authorisation__c = true; ///coPOList[i].PO_Item__c = '001'; } } insert coPOList; } //CH02.Start //Create WPD Task Record if(poLineItems != null){ WPD_Purchase_Orders__c PO = [select Purchase_Order_Value__c, Purchase_Order_Duration__c from WPD_Purchase_Orders__c where id=:poLineItems.id]; WPD_Task__c task = new WPD_Task__c(); task.WPD_Project_Work_Instruction__c = Proj.Id; task.value__c = PO.Purchase_Order_Value__c; task.Duration__c = PO.Purchase_Order_Duration__c; insert task; //CH02.End } PageReference SchPage = new PageReference('/' + Proj.Id); //Redirect to the project record created SchPage.setRedirect(true); return SchPage; @@@@@@---Not covering.End---@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ }catch(Exception ex){ Database.rollback(sp); Proj = Proj.clone(false); work = work.clone(false); List<WPD_Co_Ordinate__c> templstCoOrdinates = coOrdinateList.clone(); coOrdinateList.clear(); for(WPD_Co_Ordinate__c tmpCoordinate : templstCoOrdinates){ coOrdinateList.add(tmpCoordinate.clone(false)); } ///ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,String.valueOf(ex)); ///ApexPages.addMessage(msg); ApexPages.addMessages(ex); return NULL; } } } //this is for rnd n debugging public PageReference cancel() { PageReference SchPage1 = new PageReference('/home/home.jsp' );//ApexPages.currentPage(); return SchPage1; } } Test class: @isTest private with sharing class WPD_Schedule_4ControllerTest { //Covers the for loop in save method static TestMethod void WPD_Schedule_4Controller_1() { createContractRecord('03761');//CH01 WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Teams__c team = new WPD_Teams__c(name = 'Team'); insert team; proj.name = 'Project'; ///proj.Town__c='Town'; proj.Notification_No__c='123'; ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; proj.Estimated_Project_Start_Date__c = Date.today(); //insert proj; WPD_Reinstatement__c work = s4.getWork(); work.team_allocated__c = team.Id; //insert work; List<WPD_Co_Ordinate__c> cordinateList = s4.getArrCoordinate(); //WPD_Co_Ordinate__c coordinate = new WPD_Co_Ordinate__c(work__c = work.id, Latitude__c = Double.valueOf('0.1452254'), Longitude__c = Double.valueOf('-0.1452545'), easting__c = '123456', northing__c = '125463'); cordinateList[0].Easting__c='123456'; cordinateList[0].Northing__c='125463'; //cordinateList.add(coordinate); List<WPD_Purchase_Order_Line_Item__c> poList = s4.getArrPurchaseOrder(); WPD_Modules__c TestModules = new WPD_Modules__c(Description__c='TestDescription', Rate__c=2.0, Unit__c='m', Quantity__c=2, Variation_Date__c=date.today(), Category__c='Betterment', Authorisation__c=true); insert TestModules; poList[0].Module__c=TestModules.id; /*WPD_Purchase_Orders__c POLI = new WPD_Purchase_Orders__c(WPD_Projects__c = proj.Id, Purchase_Order_Value__c = 2.0, Date_Received__c = date.today()); insert POLI; WPD_Purchase_Order_Line_Item__c PO = new WPD_Purchase_Order_Line_Item__c(Project__c =proj.Id, PO_Number__c = POLI.Id, Quantity__c = 3.0, Module__c=TestModules.id); poList.add(PO);*/ List<WPD_Condition__c> conditionList = s4.getArrCondition(); conditionList[0].Condition__c = 'Test condition'; s4.save(); s4.cancel(); } //covers NOT for loop but next IF condtions static TestMethod void WPD_Schedule_4Controller_Test2() { createContractRecord('03751');//CH01 WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Teams__c team = new WPD_Teams__c(name = 'Test Team'); insert team; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; proj.name = 'Project'; proj.Estimated_Project_Start_Date__c = Date.today(); ///proj.Town__c='Town'; proj.Notification_No__c='123'; ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; WPD_Reinstatement__c work = s4.getWork(); work.team_allocated__c = team.Id; work.Notification_Type__c = 'Permit'; List<WPD_Condition__c> conditionList = s4.getArrCondition(); s4.save(); } //covers the very first IF in the save method. static TestMethod void WPD_Schedule_4Controller_Test3() { createContractRecord('03734');//CH01 WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Reinstatement__c work = s4.getWork(); proj.name = 'Project'; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; ///proj.Town__c='Town'; proj.Notification_No__c='123'; proj.Estimated_Project_Start_Date__c = Date.today(); ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; WPD_Agent__c agent=new WPD_Agent__c(); insert agent; WPD_Projects__c TestProject = new WPD_Projects__c(name = 'testProject', Account__c='123', Man_Unit__c='DY610', Product__c='123', title__c='aa', instructions__c='aa', Site_house_no__c='aa',site_street__c='street', site_town__c='town', WPD_Agent__c=agent.id,Work_Pack_Seen__c=true, Acceptance_Date__c=date.Today(), Notification_No__c='123',Date_Received__c=date.Today()); insert TestProject; s4.save(); } //CH01 public static void createContractRecord(String nameVal){ WPD_Contract__c toInsertCon =new WPD_Contract__c(Name = nameVal,Description__c = 'Test',End_Date__c = Date.today().addYears(1),Main_Contact__c = 'Test',Main_Depot__c = 'Test',Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'); insert toInsertCon; } //CH01 //CH02.Start static TestMethod void WPD_Schedule_4Controller_Test4(){ WPD_Contract__c toInsertCon =new WPD_Contract__c(Name = '1234',Description__c = 'Test',End_Date__c = Date.today().addYears(1),Main_Contact__c = 'Test',Main_Depot__c = 'Test',Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'); insert toInsertCon; WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Reinstatement__c work = s4.getWork(); proj.name = 'Project'; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; ///proj.Town__c='Town'; proj.Notification_No__c='123'; proj.Estimated_Project_Start_Date__c = Date.today()+1; Proj.Work_Type__c = 'Planned'; ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; Proj.Dig_Start_Date__c = null; WPD_Agent__c agent=new WPD_Agent__c(); insert agent; WPD_Projects__c TestProject = new WPD_Projects__c(name = 'testProject', Account__c='123', Man_Unit__c='DY610', Product__c='123', title__c='aa', instructions__c='aa', Site_house_no__c='aa',site_street__c='street', site_town__c='town', WPD_Agent__c=agent.id,Work_Pack_Seen__c=true, Acceptance_Date__c=date.Today(), Notification_No__c='123',Date_Received__c=date.Today()); insert TestProject; s4.save(); } static TestMethod void WPD_Schedule_4Controller_Test5(){ WPD_Contract__c toInsertCon =new WPD_Contract__c(Name = '1234',Description__c = 'Test',End_Date__c = Date.today().addYears(1),Main_Contact__c = 'Test',Main_Depot__c = 'Test',Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'); insert toInsertCon; WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Reinstatement__c work = s4.getWork(); proj.name = 'Project'; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; ///proj.Town__c='Town'; proj.Notification_No__c='123'; proj.Estimated_Project_Start_Date__c = Date.newInstance(2014,10,03); Proj.Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'; ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; Proj.Dig_Start_Date__c = null; WPD_Agent__c agent=new WPD_Agent__c(); insert agent; WPD_Projects__c TestProject = new WPD_Projects__c(name = 'testProject', Account__c='123', Man_Unit__c='DY610', Product__c='123', title__c='aa', instructions__c='aa', Site_house_no__c='aa',site_street__c='street', site_town__c='town', WPD_Agent__c=agent.id,Work_Pack_Seen__c=true, Acceptance_Date__c=date.Today(), Notification_No__c='123',Date_Received__c=date.Today()); insert TestProject; s4.save(); } static TestMethod void WPD_Schedule_4Controller_Test6(){ WPD_Contract__c toInsertCon =new WPD_Contract__c(Name = '1234',Description__c = 'Test',End_Date__c = Date.today().addYears(1),Main_Contact__c = 'Test',Main_Depot__c = 'Test',Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'); insert toInsertCon; WPD_Depot__c depot = new WPD_Depot__c(Name='Test'); insert depot; WPD_Schedule_4Controller s4 = new WPD_Schedule_4Controller(); WPD_Projects__c proj = s4.getProject(); WPD_Reinstatement__c work = s4.getWork(); proj.name = 'testProject'; proj.Account__c='1234'; proj.Product__c='5678'; proj.Site_House_No__c='test house no'; proj.Site_Street__c='test street'; proj.Site_Town__c='test town'; proj.Title__c='test title'; ///proj.Town__c='Town'; proj.Notification_No__c='123'; proj.Estimated_Project_Start_Date__c = Date.newInstance(2014,10,03); Proj.Work_Type__c = 'Planned GSOS;Planned;Faults;Street Light Faults;Gas & Water Multi Utility'; ///proj.Customer_Name__c='CustomerName'; proj.Depots__c=depot.id; Proj.Dig_Start_Date__c = null; WPD_Agent__c agent=new WPD_Agent__c(); insert agent; List<WPD_Co_Ordinate__c> cordinateList = s4.getArrCoordinate(); //WPD_Co_Ordinate__c coordinate = new WPD_Co_Ordinate__c(work__c = work.id, Latitude__c = Double.valueOf('0.1452254'), Longitude__c = Double.valueOf('-0.1452545'), easting__c = '123456', northing__c = '125463'); cordinateList[0].Easting__c='123456'; cordinateList[0].Northing__c='125463'; List<WPD_Purchase_Order_Line_Item__c> poList = s4.getArrPurchaseOrder(); WPD_Modules__c TestModules = new WPD_Modules__c(Description__c='TestDescription', Rate__c=2.0, Unit__c='m', Quantity__c=2, Variation_Date__c=date.today(), Category__c='Betterment', Authorisation__c=true); insert TestModules; poList[0].Module__c=TestModules.id; List<WPD_Condition__c> conditionList = s4.getArrCondition(); conditionList[0].Condition__c = 'Test condition'; WPD_Projects__c TestProject = new WPD_Projects__c(name = 'testProject', Account__c='123', Man_Unit__c='DY610', Product__c='123', title__c='aa', instructions__c='aa', Site_house_no__c='aa',site_street__c='street', site_town__c='town', WPD_Agent__c=agent.id,Work_Pack_Seen__c=true, Acceptance_Date__c=date.Today(), Notification_No__c='123',Date_Received__c=date.Today()); insert TestProject; s4.save(); } }
- TheLearner
- December 19, 2015
- Like
- 0
Improving the code coveragae
Hi Experts,
Could anyone improve my code coverage, i made red in color lines which are not covered. i mentioned the code from whr to whr not covering could anyone help me please
Could anyone improve my code coverage, i made red in color lines which are not covered. i mentioned the code from whr to whr not covering could anyone help me please
public with sharing class WPD_Schedule_4Controller { List<WPD_Condition__c> conditionList = new List<WPD_Condition__c>(); List<WPD_Co_Ordinate__c> coOrdinateList = new List<WPD_Co_Ordinate__c>(); List<WPD_Purchase_Order_Line_Item__c> coPOList = new List<WPD_Purchase_Order_Line_Item__c>(); public WPD_Projects__c Proj; public WPD_Reinstatement__c Work; public WPD_Co_Ordinate__c coOrdinate; public WPD_Purchase_Orders__c poLineItems; public WPD_Post_Code__c postCodeRec; public boolean modulePresent = false; public WPD_Reinstatement__c getWork(){ if (Work==null){ Work= new WPD_Reinstatement__c(); } return Work; } public WPD_Projects__c getProject() { if (Proj==null){ Proj = new WPD_Projects__c(); } return Proj; } public List<WPD_Condition__c> getArrCondition() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (conditionList.size()==0) { for (integer i=0; i<=12; i++) { conditionList.add(new WPD_Condition__c()); } } return conditionList; } public List<WPD_Co_Ordinate__c> getArrCoordinate() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coOrdinateList.size()==0) { for (integer i=1; i<=6; i++) { coOrdinateList.add(new WPD_Co_Ordinate__c()); } } return coOrdinateList; } public List<WPD_Purchase_Order_Line_Item__c> getArrPurchaseOrder() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coPOList.size()==0) { for (integer i=1; i<=20; i++)//CH03 { coPOList.add(new WPD_Purchase_Order_Line_Item__c()); } } return coPOList; } public PageReference save() { //Create savepoint Savepoint sp; List<WPD_Projects__c> WPDProj = [select Id, Name from WPD_Projects__c where Name =:Proj.Name]; //CH04.Start Date estimatePlanDate = Date.newInstance(2014,10,31); System.debug('estimatePlanDate = '+estimatePlanDate); List<WPD_Contract__c> wpdContracts; if(Proj.Estimated_Project_Start_Date__c != null && Proj.Work_Type__c != null) wpdContracts = new List<WPD_Contract__c>([SELECT Id,Name,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (:Proj.Work_Type__c) AND End_Date__c >=: Proj.Estimated_Project_Start_Date__c order by End_Date__c ASC limit 1 ]);//CH05 else wpdContracts = new List<WPD_Contract__c>(); System.debug((Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)+','+wpdContracts.isEmpty()); //CH04.End if(WPDProj.size() > 0) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You can not save as this would create a duplicate record with Work Instruction field value [' + proj.Name + '].'); ApexPages.addMessage(msg); return NULL; } //CH02.Start else if((Proj.Work_Type__c == 'Planned' || Proj.Work_Type__c == 'Planned GSOS') && (Proj.Dig_Start_Date__c == null || Proj.Dig_End_Date__c == null)){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dig Start Date and Dig End Date are mandatory if work type is Planned or Planned GSOS'); ApexPages.addMessage(msg); return NULL; }//CH02.End //CH04.Start else if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate >= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty() && wpdContracts.size() > 1 ){ @@@@@@@@@@@--NOt covering.Start---@@@@@@@@@@@@ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Combination of Work Type and Estimated Start date does not match one individual current Contract Number record'); ApexPages.addMessage(msg); return NULL; @@@@@@@-- Not covering.End----@@@@@@@@@@@@@@@@ }else if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate && wpdContracts.isEmpty()){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'No Contract Number found with Work Type and End Date > Estimated Project Start Date.'); ApexPages.addMessage(msg); return NULL; }else{//CH04.End try{ sp = Database.setSavepoint(); if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate <= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty()){ Proj.Contract__c = wpdContracts.get(0).id; } Proj.Date_Received__c = Date.today(); insert Proj; work.WPD_Projects__c = Proj.Id; work.Works_Start_Date__c = work.Estimated_Start__c; work.Works_End_Date__c = work.Estimated_End__c; insert work; //Save Co-ordinate data for(integer i=0; i<6; i++){ if(coOrdinateList[i].Easting__c!=null || coOrdinateList[i].Northing__c!=null){ @@@@@@@@@@------Not covering.start----/@@@@@@@@@@@@@@@@@ coOrdinateList[i].Work__c = Work.Id; if(i==0){ work.Eastings_Start__c=coOrdinateList[i].Easting__c; work.Northings_Start__c=coOrdinateList[i].Northing__c; }else if(i==1){ work.Eastings_End__c=coOrdinateList[i].Easting__c; work.Northings_End__c=coOrdinateList[i].Northing__c; } } } insert coOrdinateList; update work; for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { modulePresent=true; } } if(modulePresent){ //Save Purchase Order poLineItems = new WPD_Purchase_Orders__c(); poLineItems.WPD_Projects__c = Proj.Id; poLineItems.Purchase_Order_No__c = Proj.Name; poLineItems.Date_Received__c = Date.today(); insert poLineItems; //Save Purchase Order Line Item records for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { coPOList[i].PO_Number__c = poLineItems.Id; //coPOList[i].Ordered_Rate__c = coPOList[i].Module__r.Rate__c; //Populate Ordered Rate with Rate from Module object //CH02 commented this line ///coPOList[i].Category__c = 'Not Required'; //Default Category to ‘Not Required’ ///coPOList[i].Authorisation__c = true; ///coPOList[i].PO_Item__c = '001'; } } insert coPOList; } //CH02.Start //Create WPD Task Record if(poLineItems != null){ WPD_Purchase_Orders__c PO = [select Purchase_Order_Value__c, Purchase_Order_Duration__c from WPD_Purchase_Orders__c where id=:poLineItems.id]; WPD_Task__c task = new WPD_Task__c(); task.WPD_Project_Work_Instruction__c = Proj.Id; task.value__c = PO.Purchase_Order_Value__c; task.Duration__c = PO.Purchase_Order_Duration__c; insert task; //CH02.End } PageReference SchPage = new PageReference('/' + Proj.Id); //Redirect to the project record created SchPage.setRedirect(true); return SchPage; @@@@@@@@@@ ----Not covering. End-----@@@@@@@@@@@@@@@@ }catch(Exception ex){ Database.rollback(sp); Proj = Proj.clone(false); work = work.clone(false); List<WPD_Co_Ordinate__c> templstCoOrdinates = coOrdinateList.clone(); coOrdinateList.clear(); for(WPD_Co_Ordinate__c tmpCoordinate : templstCoOrdinates){ coOrdinateList.add(tmpCoordinate.clone(false)); } ///ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,String.valueOf(ex)); ///ApexPages.addMessage(msg); ApexPages.addMessages(ex); return NULL; } } } //this is for rnd n debugging public PageReference cancel() { PageReference SchPage1 = new PageReference('/home/home.jsp' );//ApexPages.currentPage(); return SchPage1; } } public with sharing class WPD_Schedule_4Controller { List<WPD_Condition__c> conditionList = new List<WPD_Condition__c>(); List<WPD_Co_Ordinate__c> coOrdinateList = new List<WPD_Co_Ordinate__c>(); List<WPD_Purchase_Order_Line_Item__c> coPOList = new List<WPD_Purchase_Order_Line_Item__c>(); public WPD_Projects__c Proj; public WPD_Reinstatement__c Work; public WPD_Co_Ordinate__c coOrdinate; public WPD_Purchase_Orders__c poLineItems; public WPD_Post_Code__c postCodeRec; public boolean modulePresent = false; public WPD_Reinstatement__c getWork(){ if (Work==null){ Work= new WPD_Reinstatement__c(); } return Work; } public WPD_Projects__c getProject() { if (Proj==null){ Proj = new WPD_Projects__c(); } return Proj; } public List<WPD_Condition__c> getArrCondition() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (conditionList.size()==0) { for (integer i=0; i<=12; i++) { conditionList.add(new WPD_Condition__c()); } } return conditionList; } public List<WPD_Co_Ordinate__c> getArrCoordinate() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coOrdinateList.size()==0) { for (integer i=1; i<=6; i++) { coOrdinateList.add(new WPD_Co_Ordinate__c()); } } return coOrdinateList; } public List<WPD_Purchase_Order_Line_Item__c> getArrPurchaseOrder() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coPOList.size()==0) { for (integer i=1; i<=20; i++)//CH03 { coPOList.add(new WPD_Purchase_Order_Line_Item__c()); } } return coPOList; } public PageReference save() { //Create savepoint Savepoint sp; List<WPD_Projects__c> WPDProj = [select Id, Name from WPD_Projects__c where Name =:Proj.Name]; //CH04.Start Date estimatePlanDate = Date.newInstance(2014,10,31); System.debug('estimatePlanDate = '+estimatePlanDate); List<WPD_Contract__c> wpdContracts; if(Proj.Estimated_Project_Start_Date__c != null && Proj.Work_Type__c != null) wpdContracts = new List<WPD_Contract__c>([SELECT Id,Name,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (:Proj.Work_Type__c) AND End_Date__c >=: Proj.Estimated_Project_Start_Date__c order by End_Date__c ASC limit 1 ]);//CH05 else wpdContracts = new List<WPD_Contract__c>(); System.debug((Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)+','+wpdContracts.isEmpty()); //CH04.End if(WPDProj.size() > 0) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You can not save as this would create a duplicate record with Work Instruction field value [' + proj.Name + '].'); ApexPages.addMessage(msg); return NULL; } //CH02.Start else if((Proj.Work_Type__c == 'Planned' || Proj.Work_Type__c == 'Planned GSOS') && (Proj.Dig_Start_Date__c == null || Proj.Dig_End_Date__c == null)){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dig Start Date and Dig End Date are mandatory if work type is Planned or Planned GSOS'); ApexPages.addMessage(msg); return NULL; }//CH02.End //CH04.Start else if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate >= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty() && wpdContracts.size() > 1 ){ not cover /* ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Combination of Work Type and Estimated Start date does not match one individual current Contract Number record'); ApexPages.addMessage(msg); return NULL;*/ not cover }else if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate && wpdContracts.isEmpty()){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'No Contract Number found with Work Type and End Date > Estimated Project Start Date.'); ApexPages.addMessage(msg); return NULL; }else{//CH04.End try{ sp = Database.setSavepoint(); if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate <= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty()){ Proj.Contract__c = wpdContracts.get(0).id; } Proj.Date_Received__c = Date.today(); insert Proj; work.WPD_Projects__c = Proj.Id; work.Works_Start_Date__c = work.Estimated_Start__c; work.Works_End_Date__c = work.Estimated_End__c; insert work; //Save Co-ordinate data for(integer i=0; i<6; i++){ if(coOrdinateList[i].Easting__c!=null || coOrdinateList[i].Northing__c!=null){ not cover /* coOrdinateList[i].Work__c = Work.Id; if(i==0){ work.Eastings_Start__c=coOrdinateList[i].Easting__c; work.Northings_Start__c=coOrdinateList[i].Northing__c; }else if(i==1){ work.Eastings_End__c=coOrdinateList[i].Easting__c; work.Northings_End__c=coOrdinateList[i].Northing__c; } } } insert coOrdinateList; update work; for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { modulePresent=true; } } if(modulePresent){ //Save Purchase Order poLineItems = new WPD_Purchase_Orders__c(); poLineItems.WPD_Projects__c = Proj.Id; poLineItems.Purchase_Order_No__c = Proj.Name; poLineItems.Date_Received__c = Date.today(); insert poLineItems; //Save Purchase Order Line Item records for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { coPOList[i].PO_Number__c = poLineItems.Id; //coPOList[i].Ordered_Rate__c = coPOList[i].Module__r.Rate__c; //Populate Ordered Rate with Rate from Module object //CH02 commented this line ///coPOList[i].Category__c = 'Not Required'; //Default Category to ‘Not Required’ ///coPOList[i].Authorisation__c = true; ///coPOList[i].PO_Item__c = '001'; } } insert coPOList; } //CH02.Start //Create WPD Task Record if(poLineItems != null){ WPD_Purchase_Orders__c PO = [select Purchase_Order_Value__c, Purchase_Order_Duration__c from WPD_Purchase_Orders__c where id=:poLineItems.id]; WPD_Task__c task = new WPD_Task__c(); task.WPD_Project_Work_Instruction__c = Proj.Id; task.value__c = PO.Purchase_Order_Value__c; task.Duration__c = PO.Purchase_Order_Duration__c; insert task; //CH02.End } PageReference SchPage = new PageReference('/' + Proj.Id); //Redirect to the project record created SchPage.setRedirect(true); return SchPage; */ not cover }catch(Exception ex){ Database.rollback(sp); Proj = Proj.clone(false); work = work.clone(false); List<WPD_Co_Ordinate__c> templstCoOrdinates = coOrdinateList.clone(); coOrdinateList.clear(); for(WPD_Co_Ordinate__c tmpCoordinate : templstCoOrdinates){ coOrdinateList.add(tmpCoordinate.clone(false)); } ///ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,String.valueOf(ex)); ///ApexPages.addMessage(msg); ApexPages.addMessages(ex); return NULL; } } } //this is for rnd n debugging public PageReference cancel() { PageReference SchPage1 = new PageReference('/home/home.jsp' );//ApexPages.currentPage(); return SchPage1; } }
- TheLearner
- December 19, 2015
- Like
- 0
Refering the formula field from another formula field--urgent
Refering the formula field from another formula field--urgent
Hi Experts,
I have formula field called Notice Warning(Notice_Warning__c) it contain warning messages , i have another formula field called This is Validity__c(formula(Text)) , now my requirement is that , when ever below conditions occur in record i need to restrict the Notice Warning formula field message in the record as they amend in the below formula field. help me out please.
This is formula for Notice Warning: i need to amend the below c, d, e , conditions in this formula field not to display , here Notice_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should not show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should not show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should not show Notice Warning – Not specific to Road Type)
Hi Experts,
I have formula field called Notice Warning(Notice_Warning__c) it contain warning messages , i have another formula field called This is Validity__c(formula(Text)) , now my requirement is that , when ever below conditions occur in record i need to restrict the Notice Warning formula field message in the record as they amend in the below formula field. help me out please.
This is formula for Notice Warning: i need to amend the below c, d, e , conditions in this formula field not to display , here Notice_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should not show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should not show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should not show Notice Warning – Not specific to Road Type)
- TheLearner
- December 16, 2015
- Like
- 0
calling formula field in other formula field--urgent
Hi Experts,
My requirment is that i need to restrict the Notice Warning(Notice_Warning__c) msg in the record which is formula(Text) field, now i need to populate this error messages based on this condition : here Notice_Type__c is picklist value and Validity__c formula fields.
this is Notice Warning(Notice_Warning__c) formula (we need to restrict this msgs based on the below condtions)
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
This is Validity__c(formula(Text))
CASE(Text(Notice_Type__c), '3 Day', '2 days','10 Day','5 days','3 Month','5 days','Immediate Emergency','within 2 hours','Immediate Urgent','within 2 hours','Private','n/a','Private Non Noticeable','n/a','')
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should no show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
My requirment is that i need to restrict the Notice Warning(Notice_Warning__c) msg in the record which is formula(Text) field, now i need to populate this error messages based on this condition : here Notice_Type__c is picklist value and Validity__c formula fields.
this is Notice Warning(Notice_Warning__c) formula (we need to restrict this msgs based on the below condtions)
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
This is Validity__c(formula(Text))
CASE(Text(Notice_Type__c), '3 Day', '2 days','10 Day','5 days','3 Month','5 days','Immediate Emergency','within 2 hours','Immediate Urgent','within 2 hours','Private','n/a','Private Non Noticeable','n/a','')
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should no show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
- TheLearner
- December 15, 2015
- Like
- 0
Changing the font color based on the condition--urgent
Hi Experts,
I need to change the font color based on the condition.
here Notice_Warning__c is forumula field, i need to change the font color of this particular condition only which i bolded below. could anyone help me please. this is my visualforce page which displaying red in color
<apex:page standardController="TW_Notice__c" >
<table width="100%" cellspacing="0">
<tr>
<td width="165px" align="right" valign="top">
<b><font color="#595959">
<apex:outputLabel value="Notice Warning" for="warn"/> </font>
</b>
</td>
<td valign="top">
<table cellspacing="0">
<tr>
<td width="15px">
</td>
<td>
<font color="red">
<apex:outputField value="{!TW_Notice__c.Notice_Warning__c}" id="warn"/>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</apex:page>
here is the formula:
Traffic_Sensitive__c is formula field which comes from the its parent record,Road_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration', (this msg need to display in blue color)
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
I need to change the font color based on the condition.
here Notice_Warning__c is forumula field, i need to change the font color of this particular condition only which i bolded below. could anyone help me please. this is my visualforce page which displaying red in color
<apex:page standardController="TW_Notice__c" >
<table width="100%" cellspacing="0">
<tr>
<td width="165px" align="right" valign="top">
<b><font color="#595959">
<apex:outputLabel value="Notice Warning" for="warn"/> </font>
</b>
</td>
<td valign="top">
<table cellspacing="0">
<tr>
<td width="15px">
</td>
<td>
<font color="red">
<apex:outputField value="{!TW_Notice__c.Notice_Warning__c}" id="warn"/>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</apex:page>
here is the formula:
Traffic_Sensitive__c is formula field which comes from the its parent record,Road_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration', (this msg need to display in blue color)
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
- TheLearner
- December 15, 2015
- Like
- 0
Checkbox should be true and false based on the text value--- urgent
Hi Experts,
My requriment is that when i enter the values in the text box checkbox should be checked,if i remove the value in the text box , checkbox should be unchecked, but in my code checkbox are getting unchecked without removing the values in the text box, could anyone help me please. here Condition_Text__c , NCT01a_Date_Constraint__c ,NCT01b_Date_Constraint__c are long text area and NCT01_Date_Constraints__c is checkbox. one more thing is that for the 2 text valeus there is only one checkbox it should be unchecked when there is no value in the both text boxs, if anyone contain value it should be checked
trigger Update_Condition_Text on SCC__c (Before insert, Before update) {
String newConditionType='';
for(SCC__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT01a_Date_Constraint__c !='' && swCon.NCT01a_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c; //CH01.Old
system.debug('initial date check' + swCon.NCT01a_Date_Constraint__c);
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
system.debug('initial date check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=True;
system.debug('checkbox date check' + swCon.NCT01_Date_Constraints__c);
}
else
{
system.debug('Pleaes check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=false;
system.debug('what check' + swCon.NCT01_Date_Constraints__c);
}
if(swCon.NCT01b_Date_Constraint__c !='' && swCon.NCT01b_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c; //CH01.Old
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('@@@@@@' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
}
}
if(trigger.isUpdate)
{
if((swCon.NCT01a_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01a_Date_Constraint__c) && swCon.NCT01a_Date_Constraint__c != null && swCon.NCT01a_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c;//CH01.Old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('######' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('$$$$$$$$' + swCon.NCT01_Date_Constraints__c);
}
//CH01.New.End
if((swCon.NCT01b_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01b_Date_Constraint__c) && swCon.NCT01b_Date_Constraint__c != null && swCon.NCT01b_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c;//CH01.old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('!!!!!!!' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('&&&&&&&' + swCon.NCT01_Date_Constraints__c);
}
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
My requriment is that when i enter the values in the text box checkbox should be checked,if i remove the value in the text box , checkbox should be unchecked, but in my code checkbox are getting unchecked without removing the values in the text box, could anyone help me please. here Condition_Text__c , NCT01a_Date_Constraint__c ,NCT01b_Date_Constraint__c are long text area and NCT01_Date_Constraints__c is checkbox. one more thing is that for the 2 text valeus there is only one checkbox it should be unchecked when there is no value in the both text boxs, if anyone contain value it should be checked
trigger Update_Condition_Text on SCC__c (Before insert, Before update) {
String newConditionType='';
for(SCC__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT01a_Date_Constraint__c !='' && swCon.NCT01a_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c; //CH01.Old
system.debug('initial date check' + swCon.NCT01a_Date_Constraint__c);
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
system.debug('initial date check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=True;
system.debug('checkbox date check' + swCon.NCT01_Date_Constraints__c);
}
else
{
system.debug('Pleaes check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=false;
system.debug('what check' + swCon.NCT01_Date_Constraints__c);
}
if(swCon.NCT01b_Date_Constraint__c !='' && swCon.NCT01b_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c; //CH01.Old
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('@@@@@@' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
}
}
if(trigger.isUpdate)
{
if((swCon.NCT01a_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01a_Date_Constraint__c) && swCon.NCT01a_Date_Constraint__c != null && swCon.NCT01a_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c;//CH01.Old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('######' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('$$$$$$$$' + swCon.NCT01_Date_Constraints__c);
}
//CH01.New.End
if((swCon.NCT01b_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01b_Date_Constraint__c) && swCon.NCT01b_Date_Constraint__c != null && swCon.NCT01b_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c;//CH01.old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('!!!!!!!' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('&&&&&&&' + swCon.NCT01_Date_Constraints__c);
}
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
- TheLearner
- December 06, 2015
- Like
- 0
Concating the text while displaying the record
Hi Experts,
My requirement is that, i enter the value in the Text box field called NCT09a Traffic Management(NCT09a_Traffic_Management__c )= 'two way lights to be used'. Then i have field called Condition Text(Condition_Text__c ) in that box value has to display like this 'NCT09a two way traffic lights to be used'. This is my trigger ,like this there are 20 fields are there i will enter the in those fields and values has to display in that field ,but i posted only one field , could anyone help me please.
trigger Update_Condition_Text on SW_Condition__c (before insert, before update)
{
String newConditionType='';
for(SW_Condition__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT09a_Traffic_Management__c !='' && swCon.NCT09a_Traffic_Management__c != null)
newConditionType = newConditionType + ', NCT09a Traffic Management : '+swCon.NCT09a_Traffic_Management__c ;
}
if(trigger.isUpdate)
{
if((swCon.NCT09a_Traffic_Management__c !=Trigger.oldMap.get(swCon.ID).NCT09a_Traffic_Management__c) && swCon.NCT09a_Traffic_Management__c != null && swCon.NCT09a_Traffic_Management__c !='')
newConditionType = newConditionType + ', NCT09a Traffic Management: '+swCon.NCT09a_Traffic_Management__c;
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
My requirement is that, i enter the value in the Text box field called NCT09a Traffic Management(NCT09a_Traffic_Management__c )= 'two way lights to be used'. Then i have field called Condition Text(Condition_Text__c ) in that box value has to display like this 'NCT09a two way traffic lights to be used'. This is my trigger ,like this there are 20 fields are there i will enter the in those fields and values has to display in that field ,but i posted only one field , could anyone help me please.
trigger Update_Condition_Text on SW_Condition__c (before insert, before update)
{
String newConditionType='';
for(SW_Condition__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT09a_Traffic_Management__c !='' && swCon.NCT09a_Traffic_Management__c != null)
newConditionType = newConditionType + ', NCT09a Traffic Management : '+swCon.NCT09a_Traffic_Management__c ;
}
if(trigger.isUpdate)
{
if((swCon.NCT09a_Traffic_Management__c !=Trigger.oldMap.get(swCon.ID).NCT09a_Traffic_Management__c) && swCon.NCT09a_Traffic_Management__c != null && swCon.NCT09a_Traffic_Management__c !='')
newConditionType = newConditionType + ', NCT09a Traffic Management: '+swCon.NCT09a_Traffic_Management__c;
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
- TheLearner
- December 03, 2015
- Like
- 0
Checkbox should be true, when i enter the value in the text box-- urgent
Hi Experts,
I have requirement that is If text is entered in field NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), on selecting Save button, check box field NCT04 Material & Plant Storage((NCT04_Material_Plant_Storage__c) should be true,
If text is removed/deleted from field the NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), corresponding chek box field is unchecked =(false). like this there are 11 text fields and 11 checkbox fields are there. Could you anyone help me please
I have requirement that is If text is entered in field NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), on selecting Save button, check box field NCT04 Material & Plant Storage((NCT04_Material_Plant_Storage__c) should be true,
If text is removed/deleted from field the NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), corresponding chek box field is unchecked =(false). like this there are 11 text fields and 11 checkbox fields are there. Could you anyone help me please
- TheLearner
- December 02, 2015
- Like
- 0
how to use custom label-- urgent
Hi Experts,
I have custom lable it contain 5 email ids, so i want to use it in the apex class, could anyone tell me how to use it please, because custom label support only one string it thrwoing an error because im using more than one in the label.
I have custom lable it contain 5 email ids, so i want to use it in the apex class, could anyone tell me how to use it please, because custom label support only one string it thrwoing an error because im using more than one in the label.
- TheLearner
- November 26, 2015
- Like
- 0
Amending the custom label in the apex class
Hi Experts,
I need to add custom label in the below code, could anyone tell me how to use it, because, its heierachy kind links are there so how to add could anyone help me please.
Current_User_Email__c from SW_Notice__c where id =: System.currentPageReference().getParameters().get('id') ];
String [] toAddresses;
if(notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c!=null){ //CH01
toAddresses = new String[] {notices[0].Current_User_Email__c , notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c,'test@test.com'}; //CH01
//toAddresses = new String[] {notices[0].Current_User_Email__c , notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c,'test@test.in'}; //CH01
}else{
toAddresses = new String[] {notices[0].Current_User_Email__c,'test@test.com'};
//toAddresses = new String[] {notices[0].Current_User_Email__c,'test@test.in' };
}
I need to add custom label in the below code, could anyone tell me how to use it, because, its heierachy kind links are there so how to add could anyone help me please.
Current_User_Email__c from SW_Notice__c where id =: System.currentPageReference().getParameters().get('id') ];
String [] toAddresses;
if(notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c!=null){ //CH01
toAddresses = new String[] {notices[0].Current_User_Email__c , notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c,'test@test.com'}; //CH01
//toAddresses = new String[] {notices[0].Current_User_Email__c , notices[0].SW_Street_Project_Name__r.Project_Ref__r.Project_Manager__r.Email__c,'test@test.in'}; //CH01
}else{
toAddresses = new String[] {notices[0].Current_User_Email__c,'test@test.com'};
//toAddresses = new String[] {notices[0].Current_User_Email__c,'test@test.in' };
}
- TheLearner
- November 25, 2015
- Like
- 0
Need to Restricting to profile for the edit
HI Experts,
I have requirment there is profile 'ABC' this profile have object called 'Orgnisation' which contain Read , Edit, Create, view all permission for this profile,
my requirement is that there is picklist field called 'Orgnistaion_Type__c'. Now requirment is that if Orgnistaion_Type__c= 'supplier' then i need to provide Read and Edit access for the user ,if other than 'supplier' i need to provide Ready access only, if user try to edit such record by the user i need to provide an error message.
I have requirment there is profile 'ABC' this profile have object called 'Orgnisation' which contain Read , Edit, Create, view all permission for this profile,
my requirement is that there is picklist field called 'Orgnistaion_Type__c'. Now requirment is that if Orgnistaion_Type__c= 'supplier' then i need to provide Read and Edit access for the user ,if other than 'supplier' i need to provide Ready access only, if user try to edit such record by the user i need to provide an error message.
- TheLearner
- November 23, 2015
- Like
- 0
Need to display forth coming date
Hi Experts,
if Project.Estimated_Project_Start_Date__c != null AND Proj.Work_Type__c != null then it will select all those WPD Contracts which are having
WPD Contract.Work_Type__c matching the WPD Project.Work_Type__c
AND
WPD Contract.End_Date__c >= Project.Estimated_Project_Start_Date__c
Should the above formula fetch two possible solutions (Contract records) then choose the Contract Number based on the nearest forthcoming End Date.
i.e. Contract Number 03805 and 03806 found Estimated Project Start Date = 23/09/2015.
03805 has an End Date of 31/10/2015
03806 has an End Date of 31/10/2016
Therefore i need to display as the nearest forthcoming date = 31/10/2015 select the Contract Number as 03805. Could anyone help me where i need to make an amendment please.
trigger WPD_UpdateWorkPackSeenDate_Project on WPD_Projects__c (before insert, before update) {
map<id,boolean> mapWPS_New = new map<id,boolean>();
map<id,boolean> mapWPS_Old = new map<id,boolean>();
if(trigger.isinsert){
for(WPD_Projects__c project : trigger.new){
if(project.Work_Pack_Seen__c==true)
project.Work_Pack_Seen_Date__c=system.today();
}
}
else if(trigger.isupdate){
for(WPD_Projects__c NewProj : trigger.new)
mapWPS_New.put(NewProj.id,NewProj.Work_Pack_Seen__c);
for(WPD_Projects__c OldProj : trigger.old)
mapWPS_Old.put(OldProj.id,OldProj.Work_Pack_Seen__c);
for(WPD_Projects__c proj : trigger.new){
system.debug('rrrrr-----'+mapWPS_New.get(proj.id));
system.debug('tttttt-----'+mapWPS_Old.get(proj.id));
system.debug('wwwwww-----'+proj.Work_Pack_Seen__c);
if(mapWPS_New.get(proj.id)!=mapWPS_Old.get(proj.id) && proj.Work_Pack_Seen__c==true)
proj.Work_Pack_Seen_Date__c=system.today();
}
}
//CH01.Start
Set<Date> setDates = new Set<Date>();
Set<String> setWorkType = new Set<String>();
Date estimatePlanDate = Date.newInstance(2014,10,31);//condition needs to satisfy for above dates only
//select all the Work types
for(WPD_Projects__c Proj:trigger.new){
System.debug(Proj.Estimated_Project_Start_Date__c+'= '+(Proj.Estimated_Project_Start_Date__c >= estimatePlanDate));
if(Proj.Contract__c != null && Proj.Work_Type__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)
setWorkType.add(Proj.Contract__c);
}
Map<String,WPD_Contract__c> mapContract = new Map<String,WPD_Contract__c>();
if(!setWorkType.isEmpty())
for(WPD_Contract__c con:[SELECT Id,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE id IN:setWorkType])
mapContract.put(con.id,con);
/*
CH02
System.debug('setWorkType = '+setWorkType+' , ='+estimatePlanDate);
String queryStr = '';
//Preparing query.
if(!setWorkType.isEmpty()){
queryStr = 'SELECT Id,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (';
for(String st:setWorkType){
queryStr = queryStr+'\''+st+'\';';
}
queryStr = queryStr.subStringBeforeLast(';')+')';
System.debug('queryStr => '+queryStr+', setWorkType size = '+setWorkType.size()+', estimatePlanDate = '+estimatePlanDate);
for(WPD_Contract__c con:Database.query(queryStr))
mapContract.put(con.id,con);
}
CH02
*/
System.debug('mapContract ='+mapContract);
//condition.
for(WPD_Projects__c Proj:trigger.new){
if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate){
if(Proj.Contract__c!= null && !(Proj.Work_Type__c != null && mapContract.containsKey(Proj.Contract__c) && mapContract.get(Proj.Contract__c) != null
&& Proj.Estimated_Project_Start_Date__c <= mapContract.get(Proj.Contract__c).End_Date__c
&& mapContract.get(Proj.Contract__c).Work_Type__c.ContainsIgnoreCase(Proj.Work_Type__c))){
Proj.addError('Work Type/Estimated Project Start Date is not matched for the Contract.');
}
}
}
//CH01.End
}
if Project.Estimated_Project_Start_Date__c != null AND Proj.Work_Type__c != null then it will select all those WPD Contracts which are having
WPD Contract.Work_Type__c matching the WPD Project.Work_Type__c
AND
WPD Contract.End_Date__c >= Project.Estimated_Project_Start_Date__c
Should the above formula fetch two possible solutions (Contract records) then choose the Contract Number based on the nearest forthcoming End Date.
i.e. Contract Number 03805 and 03806 found Estimated Project Start Date = 23/09/2015.
03805 has an End Date of 31/10/2015
03806 has an End Date of 31/10/2016
Therefore i need to display as the nearest forthcoming date = 31/10/2015 select the Contract Number as 03805. Could anyone help me where i need to make an amendment please.
trigger WPD_UpdateWorkPackSeenDate_Project on WPD_Projects__c (before insert, before update) {
map<id,boolean> mapWPS_New = new map<id,boolean>();
map<id,boolean> mapWPS_Old = new map<id,boolean>();
if(trigger.isinsert){
for(WPD_Projects__c project : trigger.new){
if(project.Work_Pack_Seen__c==true)
project.Work_Pack_Seen_Date__c=system.today();
}
}
else if(trigger.isupdate){
for(WPD_Projects__c NewProj : trigger.new)
mapWPS_New.put(NewProj.id,NewProj.Work_Pack_Seen__c);
for(WPD_Projects__c OldProj : trigger.old)
mapWPS_Old.put(OldProj.id,OldProj.Work_Pack_Seen__c);
for(WPD_Projects__c proj : trigger.new){
system.debug('rrrrr-----'+mapWPS_New.get(proj.id));
system.debug('tttttt-----'+mapWPS_Old.get(proj.id));
system.debug('wwwwww-----'+proj.Work_Pack_Seen__c);
if(mapWPS_New.get(proj.id)!=mapWPS_Old.get(proj.id) && proj.Work_Pack_Seen__c==true)
proj.Work_Pack_Seen_Date__c=system.today();
}
}
//CH01.Start
Set<Date> setDates = new Set<Date>();
Set<String> setWorkType = new Set<String>();
Date estimatePlanDate = Date.newInstance(2014,10,31);//condition needs to satisfy for above dates only
//select all the Work types
for(WPD_Projects__c Proj:trigger.new){
System.debug(Proj.Estimated_Project_Start_Date__c+'= '+(Proj.Estimated_Project_Start_Date__c >= estimatePlanDate));
if(Proj.Contract__c != null && Proj.Work_Type__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)
setWorkType.add(Proj.Contract__c);
}
Map<String,WPD_Contract__c> mapContract = new Map<String,WPD_Contract__c>();
if(!setWorkType.isEmpty())
for(WPD_Contract__c con:[SELECT Id,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE id IN:setWorkType])
mapContract.put(con.id,con);
/*
CH02
System.debug('setWorkType = '+setWorkType+' , ='+estimatePlanDate);
String queryStr = '';
//Preparing query.
if(!setWorkType.isEmpty()){
queryStr = 'SELECT Id,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (';
for(String st:setWorkType){
queryStr = queryStr+'\''+st+'\';';
}
queryStr = queryStr.subStringBeforeLast(';')+')';
System.debug('queryStr => '+queryStr+', setWorkType size = '+setWorkType.size()+', estimatePlanDate = '+estimatePlanDate);
for(WPD_Contract__c con:Database.query(queryStr))
mapContract.put(con.id,con);
}
CH02
*/
System.debug('mapContract ='+mapContract);
//condition.
for(WPD_Projects__c Proj:trigger.new){
if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate){
if(Proj.Contract__c!= null && !(Proj.Work_Type__c != null && mapContract.containsKey(Proj.Contract__c) && mapContract.get(Proj.Contract__c) != null
&& Proj.Estimated_Project_Start_Date__c <= mapContract.get(Proj.Contract__c).End_Date__c
&& mapContract.get(Proj.Contract__c).Work_Type__c.ContainsIgnoreCase(Proj.Work_Type__c))){
Proj.addError('Work Type/Estimated Project Start Date is not matched for the Contract.');
}
}
}
//CH01.End
}
- TheLearner
- November 18, 2015
- Like
- 0
Restricting the profile based ont picklist values
Hi Experts,
I need to write validaton rule for this scenario, Could you help me please
If profile='SCC Procurement' user select the Organisation_Type__c='Supplier' then we need to provide Read and Edit access for that profile user, if the user selects the Organisation_Type__c !='Supplier' then we need to Provide only Read access and if he try to edit the record we need to provide error msg . could anyone help me please
I need to write validaton rule for this scenario, Could you help me please
If profile='SCC Procurement' user select the Organisation_Type__c='Supplier' then we need to provide Read and Edit access for that profile user, if the user selects the Organisation_Type__c !='Supplier' then we need to Provide only Read access and if he try to edit the record we need to provide error msg . could anyone help me please
- TheLearner
- November 18, 2015
- Like
- 0
Trigger to populate the recent value in the fileds
Hi Experts,
My requirment is i have object called Site__C it contains fields called , Public_Site_Clear__c,Private_Site_Clear__c,Site_Clear__c so what we need to do that
When Public Site Clear(Public_Site_Clear__c) and Private Site Clear(Private_Site_Clear__c) dates are both populated, trigger the update (on initial population only) of the Site Clear(Site_Clear__c) field with the latest date. i.e Public Site Clear = 23/10/2015, Private Site Clear = 02/11/2015, therefore Site Clear = 02/11/2015. If the dates are subsequently changed then do nothing.
Could anyone help me pleaase
My requirment is i have object called Site__C it contains fields called , Public_Site_Clear__c,Private_Site_Clear__c,Site_Clear__c so what we need to do that
When Public Site Clear(Public_Site_Clear__c) and Private Site Clear(Private_Site_Clear__c) dates are both populated, trigger the update (on initial population only) of the Site Clear(Site_Clear__c) field with the latest date. i.e Public Site Clear = 23/10/2015, Private Site Clear = 02/11/2015, therefore Site Clear = 02/11/2015. If the dates are subsequently changed then do nothing.
Could anyone help me pleaase
- TheLearner
- November 13, 2015
- Like
- 0
Giving read and edit permission for the profile
Hi Experts,
I need to write validaton rule for this scenario, Could you help me please
If profile='SCC Procurement' select the Organisation_Type__c='Supplier' then we need to provide Read and Edit access for the user, if the Organisation_Type__c !='Supplier' then we need to Provide only Read access and if he try to edit the record we need to provide error msg
I need to write validaton rule for this scenario, Could you help me please
If profile='SCC Procurement' select the Organisation_Type__c='Supplier' then we need to provide Read and Edit access for the user, if the Organisation_Type__c !='Supplier' then we need to Provide only Read access and if he try to edit the record we need to provide error msg
- TheLearner
- November 13, 2015
- Like
- 0
changing the date format in the apex class
Hi Experts,
I need to change the format of Installation_Date__c into YYYY-MM-DD,here is the code where Installation_Date__c field is used , could anyone help me please
for(TWM_Meter__c meter : [select id, Meter_Location__c, Meter_Box_Type__c, Exact_location_of_Meter__c, Meter_Grid_Ref_No__c,
Serial_No__r.Name, In_Line_or_Concentric__c, Meter_Make__c, Meter_Type__c, Meter_Size__c, Flow_Rate__c, No_of_Dials__c,
Manufactured_year__c, Last_Reading__c, Installation_Date__c, LCE_Fitted__c, LCE_Reader_Serial_No__c,
LCE_Location__c, LCE_Grid_Ref__c, New_Radio_ID__c, Pulse__c, Property_Outer_Postcode__c,Property_Inner_Postcode__c,
Northings__c, Eastings__c, Exchange_Radio_ID__c, Task__r.Job__c,
Meter_Location_Description__c, Task__r.name, // CH04
Tech_Type__c,DMA__c,MIU_fitted__c,New_MIU_Reader_Serial_Number__c,MIU_location__c,MIU_Grid_ref__c from TWM_Meter__c where Task__r.Job__c in : mapJobTasks.keySet()
AND ((Installation_Date__c >=:twmJobInst.Required_Start_Date__c //CH09
AND Installation_Date__c <=:twmJobInst.Required_Completion_Date__c)//CH09
OR (Installation_Date__c = null))//CH09
order by Task__r.name]){ //CH04 Added order by // CH06.New
strItemRow += formatDate(meter.Installation_Date__c) + '|';
- TheLearner
- November 10, 2015
- Like
- 0
changing the status by clicking on check box
Hi Experts,
I need to change the status when i check the checkbox, i need to amend in the code . could you anyone help me
Please call this new field “Defect_on_Hold__c” - checkbox. When checked, the Activity Status(Activity_Status__c) needs to change from "INTrR" to "HOLD".
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');
}
}
}
}
}
}
}
I need to change the status when i check the checkbox, i need to amend in the code . could you anyone help me
Please call this new field “Defect_on_Hold__c” - checkbox. When checked, the Activity Status(Activity_Status__c) needs to change from "INTrR" to "HOLD".
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');
}
}
}
}
}
}
}
- TheLearner
- October 31, 2015
- Like
- 1
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'
)
)
- TheLearner
- October 16, 2015
- Like
- 1
Very urgent.........regarding formula fields
Hi Experts,
I have one requirment i need to test all the formula fields in my org whether they are working or not , please provide me soluation with examples so that i will test please...
Thanks in adavance
I have one requirment i need to test all the formula fields in my org whether they are working or not , please provide me soluation with examples so that i will test please...
Thanks in adavance
- TheLearner
- April 08, 2015
- Like
- 1
Create a trigger to allow button to create rule
Hi, I am trying to create a trigger to allow a button when click to create a rule. We need to be able to have a message state a comp is required after clicking the submit button if a comp has not been entered.
HELP please.
HELP please.
- Heather Farkas
- February 03, 2016
- Like
- 0
Providing space in excel file
Hi Experts,
I am rendering visualforce page as Excel file, i need to provide sapce between two lines , i tried with  , some other tags and css its not wokring at all, could anyone tell me how to do that.
<tr>
<td><b>Display requried</b>
diplay while records (Please choose one of the field )</td></tr>
i want to display like this could anyone help me please
I am rendering visualforce page as Excel file, i need to provide sapce between two lines , i tried with  , some other tags and css its not wokring at all, could anyone tell me how to do that.
<tr>
<td><b>Display requried</b>
diplay while records (Please choose one of the field )</td></tr>
i want to display like this could anyone help me please
- TheLearner
- January 19, 2016
- Like
- 0
Improving the code coveragae
Hi Experts,
Could anyone improve my code coverage, i made red in color lines which are not covered. i mentioned the code from whr to whr not covering could anyone help me please
Could anyone improve my code coverage, i made red in color lines which are not covered. i mentioned the code from whr to whr not covering could anyone help me please
public with sharing class WPD_Schedule_4Controller { List<WPD_Condition__c> conditionList = new List<WPD_Condition__c>(); List<WPD_Co_Ordinate__c> coOrdinateList = new List<WPD_Co_Ordinate__c>(); List<WPD_Purchase_Order_Line_Item__c> coPOList = new List<WPD_Purchase_Order_Line_Item__c>(); public WPD_Projects__c Proj; public WPD_Reinstatement__c Work; public WPD_Co_Ordinate__c coOrdinate; public WPD_Purchase_Orders__c poLineItems; public WPD_Post_Code__c postCodeRec; public boolean modulePresent = false; public WPD_Reinstatement__c getWork(){ if (Work==null){ Work= new WPD_Reinstatement__c(); } return Work; } public WPD_Projects__c getProject() { if (Proj==null){ Proj = new WPD_Projects__c(); } return Proj; } public List<WPD_Condition__c> getArrCondition() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (conditionList.size()==0) { for (integer i=0; i<=12; i++) { conditionList.add(new WPD_Condition__c()); } } return conditionList; } public List<WPD_Co_Ordinate__c> getArrCoordinate() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coOrdinateList.size()==0) { for (integer i=1; i<=6; i++) { coOrdinateList.add(new WPD_Co_Ordinate__c()); } } return coOrdinateList; } public List<WPD_Purchase_Order_Line_Item__c> getArrPurchaseOrder() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coPOList.size()==0) { for (integer i=1; i<=20; i++)//CH03 { coPOList.add(new WPD_Purchase_Order_Line_Item__c()); } } return coPOList; } public PageReference save() { //Create savepoint Savepoint sp; List<WPD_Projects__c> WPDProj = [select Id, Name from WPD_Projects__c where Name =:Proj.Name]; //CH04.Start Date estimatePlanDate = Date.newInstance(2014,10,31); System.debug('estimatePlanDate = '+estimatePlanDate); List<WPD_Contract__c> wpdContracts; if(Proj.Estimated_Project_Start_Date__c != null && Proj.Work_Type__c != null) wpdContracts = new List<WPD_Contract__c>([SELECT Id,Name,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (:Proj.Work_Type__c) AND End_Date__c >=: Proj.Estimated_Project_Start_Date__c order by End_Date__c ASC limit 1 ]);//CH05 else wpdContracts = new List<WPD_Contract__c>(); System.debug((Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)+','+wpdContracts.isEmpty()); //CH04.End if(WPDProj.size() > 0) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You can not save as this would create a duplicate record with Work Instruction field value [' + proj.Name + '].'); ApexPages.addMessage(msg); return NULL; } //CH02.Start else if((Proj.Work_Type__c == 'Planned' || Proj.Work_Type__c == 'Planned GSOS') && (Proj.Dig_Start_Date__c == null || Proj.Dig_End_Date__c == null)){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dig Start Date and Dig End Date are mandatory if work type is Planned or Planned GSOS'); ApexPages.addMessage(msg); return NULL; }//CH02.End //CH04.Start else if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate >= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty() && wpdContracts.size() > 1 ){ @@@@@@@@@@@--NOt covering.Start---@@@@@@@@@@@@ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Combination of Work Type and Estimated Start date does not match one individual current Contract Number record'); ApexPages.addMessage(msg); return NULL; @@@@@@@-- Not covering.End----@@@@@@@@@@@@@@@@ }else if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate && wpdContracts.isEmpty()){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'No Contract Number found with Work Type and End Date > Estimated Project Start Date.'); ApexPages.addMessage(msg); return NULL; }else{//CH04.End try{ sp = Database.setSavepoint(); if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate <= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty()){ Proj.Contract__c = wpdContracts.get(0).id; } Proj.Date_Received__c = Date.today(); insert Proj; work.WPD_Projects__c = Proj.Id; work.Works_Start_Date__c = work.Estimated_Start__c; work.Works_End_Date__c = work.Estimated_End__c; insert work; //Save Co-ordinate data for(integer i=0; i<6; i++){ if(coOrdinateList[i].Easting__c!=null || coOrdinateList[i].Northing__c!=null){ @@@@@@@@@@------Not covering.start----/@@@@@@@@@@@@@@@@@ coOrdinateList[i].Work__c = Work.Id; if(i==0){ work.Eastings_Start__c=coOrdinateList[i].Easting__c; work.Northings_Start__c=coOrdinateList[i].Northing__c; }else if(i==1){ work.Eastings_End__c=coOrdinateList[i].Easting__c; work.Northings_End__c=coOrdinateList[i].Northing__c; } } } insert coOrdinateList; update work; for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { modulePresent=true; } } if(modulePresent){ //Save Purchase Order poLineItems = new WPD_Purchase_Orders__c(); poLineItems.WPD_Projects__c = Proj.Id; poLineItems.Purchase_Order_No__c = Proj.Name; poLineItems.Date_Received__c = Date.today(); insert poLineItems; //Save Purchase Order Line Item records for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { coPOList[i].PO_Number__c = poLineItems.Id; //coPOList[i].Ordered_Rate__c = coPOList[i].Module__r.Rate__c; //Populate Ordered Rate with Rate from Module object //CH02 commented this line ///coPOList[i].Category__c = 'Not Required'; //Default Category to ‘Not Required’ ///coPOList[i].Authorisation__c = true; ///coPOList[i].PO_Item__c = '001'; } } insert coPOList; } //CH02.Start //Create WPD Task Record if(poLineItems != null){ WPD_Purchase_Orders__c PO = [select Purchase_Order_Value__c, Purchase_Order_Duration__c from WPD_Purchase_Orders__c where id=:poLineItems.id]; WPD_Task__c task = new WPD_Task__c(); task.WPD_Project_Work_Instruction__c = Proj.Id; task.value__c = PO.Purchase_Order_Value__c; task.Duration__c = PO.Purchase_Order_Duration__c; insert task; //CH02.End } PageReference SchPage = new PageReference('/' + Proj.Id); //Redirect to the project record created SchPage.setRedirect(true); return SchPage; @@@@@@@@@@ ----Not covering. End-----@@@@@@@@@@@@@@@@ }catch(Exception ex){ Database.rollback(sp); Proj = Proj.clone(false); work = work.clone(false); List<WPD_Co_Ordinate__c> templstCoOrdinates = coOrdinateList.clone(); coOrdinateList.clear(); for(WPD_Co_Ordinate__c tmpCoordinate : templstCoOrdinates){ coOrdinateList.add(tmpCoordinate.clone(false)); } ///ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,String.valueOf(ex)); ///ApexPages.addMessage(msg); ApexPages.addMessages(ex); return NULL; } } } //this is for rnd n debugging public PageReference cancel() { PageReference SchPage1 = new PageReference('/home/home.jsp' );//ApexPages.currentPage(); return SchPage1; } } public with sharing class WPD_Schedule_4Controller { List<WPD_Condition__c> conditionList = new List<WPD_Condition__c>(); List<WPD_Co_Ordinate__c> coOrdinateList = new List<WPD_Co_Ordinate__c>(); List<WPD_Purchase_Order_Line_Item__c> coPOList = new List<WPD_Purchase_Order_Line_Item__c>(); public WPD_Projects__c Proj; public WPD_Reinstatement__c Work; public WPD_Co_Ordinate__c coOrdinate; public WPD_Purchase_Orders__c poLineItems; public WPD_Post_Code__c postCodeRec; public boolean modulePresent = false; public WPD_Reinstatement__c getWork(){ if (Work==null){ Work= new WPD_Reinstatement__c(); } return Work; } public WPD_Projects__c getProject() { if (Proj==null){ Proj = new WPD_Projects__c(); } return Proj; } public List<WPD_Condition__c> getArrCondition() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (conditionList.size()==0) { for (integer i=0; i<=12; i++) { conditionList.add(new WPD_Condition__c()); } } return conditionList; } public List<WPD_Co_Ordinate__c> getArrCoordinate() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coOrdinateList.size()==0) { for (integer i=1; i<=6; i++) { coOrdinateList.add(new WPD_Co_Ordinate__c()); } } return coOrdinateList; } public List<WPD_Purchase_Order_Line_Item__c> getArrPurchaseOrder() { //Add to collection only if empty, else if mandatory field error comes, it will keep adding same numbers on VF page if (coPOList.size()==0) { for (integer i=1; i<=20; i++)//CH03 { coPOList.add(new WPD_Purchase_Order_Line_Item__c()); } } return coPOList; } public PageReference save() { //Create savepoint Savepoint sp; List<WPD_Projects__c> WPDProj = [select Id, Name from WPD_Projects__c where Name =:Proj.Name]; //CH04.Start Date estimatePlanDate = Date.newInstance(2014,10,31); System.debug('estimatePlanDate = '+estimatePlanDate); List<WPD_Contract__c> wpdContracts; if(Proj.Estimated_Project_Start_Date__c != null && Proj.Work_Type__c != null) wpdContracts = new List<WPD_Contract__c>([SELECT Id,Name,Work_Type__c,End_Date__c FROM WPD_Contract__c WHERE Work_Type__c INCLUDES (:Proj.Work_Type__c) AND End_Date__c >=: Proj.Estimated_Project_Start_Date__c order by End_Date__c ASC limit 1 ]);//CH05 else wpdContracts = new List<WPD_Contract__c>(); System.debug((Proj.Estimated_Project_Start_Date__c >= estimatePlanDate)+','+wpdContracts.isEmpty()); //CH04.End if(WPDProj.size() > 0) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You can not save as this would create a duplicate record with Work Instruction field value [' + proj.Name + '].'); ApexPages.addMessage(msg); return NULL; } //CH02.Start else if((Proj.Work_Type__c == 'Planned' || Proj.Work_Type__c == 'Planned GSOS') && (Proj.Dig_Start_Date__c == null || Proj.Dig_End_Date__c == null)){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dig Start Date and Dig End Date are mandatory if work type is Planned or Planned GSOS'); ApexPages.addMessage(msg); return NULL; }//CH02.End //CH04.Start else if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate >= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty() && wpdContracts.size() > 1 ){ not cover /* ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Combination of Work Type and Estimated Start date does not match one individual current Contract Number record'); ApexPages.addMessage(msg); return NULL;*/ not cover }else if(Proj.Estimated_Project_Start_Date__c != null && Proj.Estimated_Project_Start_Date__c >= estimatePlanDate && wpdContracts.isEmpty()){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'No Contract Number found with Work Type and End Date > Estimated Project Start Date.'); ApexPages.addMessage(msg); return NULL; }else{//CH04.End try{ sp = Database.setSavepoint(); if(Proj.Estimated_Project_Start_Date__c != null && estimatePlanDate <= Proj.Estimated_Project_Start_Date__c && !wpdContracts.isEmpty()){ Proj.Contract__c = wpdContracts.get(0).id; } Proj.Date_Received__c = Date.today(); insert Proj; work.WPD_Projects__c = Proj.Id; work.Works_Start_Date__c = work.Estimated_Start__c; work.Works_End_Date__c = work.Estimated_End__c; insert work; //Save Co-ordinate data for(integer i=0; i<6; i++){ if(coOrdinateList[i].Easting__c!=null || coOrdinateList[i].Northing__c!=null){ not cover /* coOrdinateList[i].Work__c = Work.Id; if(i==0){ work.Eastings_Start__c=coOrdinateList[i].Easting__c; work.Northings_Start__c=coOrdinateList[i].Northing__c; }else if(i==1){ work.Eastings_End__c=coOrdinateList[i].Easting__c; work.Northings_End__c=coOrdinateList[i].Northing__c; } } } insert coOrdinateList; update work; for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { modulePresent=true; } } if(modulePresent){ //Save Purchase Order poLineItems = new WPD_Purchase_Orders__c(); poLineItems.WPD_Projects__c = Proj.Id; poLineItems.Purchase_Order_No__c = Proj.Name; poLineItems.Date_Received__c = Date.today(); insert poLineItems; //Save Purchase Order Line Item records for (integer i=0; i<20; i++){ if (coPOList[i].Module__c!=null) { coPOList[i].PO_Number__c = poLineItems.Id; //coPOList[i].Ordered_Rate__c = coPOList[i].Module__r.Rate__c; //Populate Ordered Rate with Rate from Module object //CH02 commented this line ///coPOList[i].Category__c = 'Not Required'; //Default Category to ‘Not Required’ ///coPOList[i].Authorisation__c = true; ///coPOList[i].PO_Item__c = '001'; } } insert coPOList; } //CH02.Start //Create WPD Task Record if(poLineItems != null){ WPD_Purchase_Orders__c PO = [select Purchase_Order_Value__c, Purchase_Order_Duration__c from WPD_Purchase_Orders__c where id=:poLineItems.id]; WPD_Task__c task = new WPD_Task__c(); task.WPD_Project_Work_Instruction__c = Proj.Id; task.value__c = PO.Purchase_Order_Value__c; task.Duration__c = PO.Purchase_Order_Duration__c; insert task; //CH02.End } PageReference SchPage = new PageReference('/' + Proj.Id); //Redirect to the project record created SchPage.setRedirect(true); return SchPage; */ not cover }catch(Exception ex){ Database.rollback(sp); Proj = Proj.clone(false); work = work.clone(false); List<WPD_Co_Ordinate__c> templstCoOrdinates = coOrdinateList.clone(); coOrdinateList.clear(); for(WPD_Co_Ordinate__c tmpCoordinate : templstCoOrdinates){ coOrdinateList.add(tmpCoordinate.clone(false)); } ///ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,String.valueOf(ex)); ///ApexPages.addMessage(msg); ApexPages.addMessages(ex); return NULL; } } } //this is for rnd n debugging public PageReference cancel() { PageReference SchPage1 = new PageReference('/home/home.jsp' );//ApexPages.currentPage(); return SchPage1; } }
- TheLearner
- December 19, 2015
- Like
- 0
calling formula field in other formula field--urgent
Hi Experts,
My requirment is that i need to restrict the Notice Warning(Notice_Warning__c) msg in the record which is formula(Text) field, now i need to populate this error messages based on this condition : here Notice_Type__c is picklist value and Validity__c formula fields.
this is Notice Warning(Notice_Warning__c) formula (we need to restrict this msgs based on the below condtions)
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
This is Validity__c(formula(Text))
CASE(Text(Notice_Type__c), '3 Day', '2 days','10 Day','5 days','3 Month','5 days','Immediate Emergency','within 2 hours','Immediate Urgent','within 2 hours','Private','n/a','Private Non Noticeable','n/a','')
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should no show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
My requirment is that i need to restrict the Notice Warning(Notice_Warning__c) msg in the record which is formula(Text) field, now i need to populate this error messages based on this condition : here Notice_Type__c is picklist value and Validity__c formula fields.
this is Notice Warning(Notice_Warning__c) formula (we need to restrict this msgs based on the below condtions)
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration',
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
This is Validity__c(formula(Text))
CASE(Text(Notice_Type__c), '3 Day', '2 days','10 Day','5 days','3 Month','5 days','Immediate Emergency','within 2 hours','Immediate Urgent','within 2 hours','Private','n/a','Private Non Noticeable','n/a','')
c) If Notice Type(Notice_Type__c(Text)) = Immediate Emergency, or Immediate Urgent
Validity(Validity__c(Text) = within 2 hours
(should no show Notice Warning – Not specific to Road Type)
d) If Notice Type field = Private
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
e) If Notice Type field = Private non noticeable
Validity = n/a
(should no show Notice Warning – Not specific to Road Type)
- TheLearner
- December 15, 2015
- Like
- 0
Changing the font color based on the condition--urgent
Hi Experts,
I need to change the font color based on the condition.
here Notice_Warning__c is forumula field, i need to change the font color of this particular condition only which i bolded below. could anyone help me please. this is my visualforce page which displaying red in color
<apex:page standardController="TW_Notice__c" >
<table width="100%" cellspacing="0">
<tr>
<td width="165px" align="right" valign="top">
<b><font color="#595959">
<apex:outputLabel value="Notice Warning" for="warn"/> </font>
</b>
</td>
<td valign="top">
<table cellspacing="0">
<tr>
<td width="15px">
</td>
<td>
<font color="red">
<apex:outputField value="{!TW_Notice__c.Notice_Warning__c}" id="warn"/>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</apex:page>
here is the formula:
Traffic_Sensitive__c is formula field which comes from the its parent record,Road_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration', (this msg need to display in blue color)
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
I need to change the font color based on the condition.
here Notice_Warning__c is forumula field, i need to change the font color of this particular condition only which i bolded below. could anyone help me please. this is my visualforce page which displaying red in color
<apex:page standardController="TW_Notice__c" >
<table width="100%" cellspacing="0">
<tr>
<td width="165px" align="right" valign="top">
<b><font color="#595959">
<apex:outputLabel value="Notice Warning" for="warn"/> </font>
</b>
</td>
<td valign="top">
<table cellspacing="0">
<tr>
<td width="15px">
</td>
<td>
<font color="red">
<apex:outputField value="{!TW_Notice__c.Notice_Warning__c}" id="warn"/>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</apex:page>
here is the formula:
Traffic_Sensitive__c is formula field which comes from the its parent record,Road_Type__c is picklist
IF
(
Traffic_Sensitive__c = 'Yes',
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
if
(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 3', Road_Type__c='Type 4')
),
'Actual Start Date can move within Validity period, and Actual End Date will slide to include the full Duration', (this msg need to display in blue color)
if(
AND(
Traffic_Sensitive__c = 'No',
OR(Road_Type__c='Type 0', Road_Type__c='Type 1', Road_Type__c='Type 2')
),
'Actual Start Date can move within Validity period, but Actual End Date will be fixed',
''
)
)
)
- TheLearner
- December 15, 2015
- Like
- 0
Checkbox should be true and false based on the text value--- urgent
Hi Experts,
My requriment is that when i enter the values in the text box checkbox should be checked,if i remove the value in the text box , checkbox should be unchecked, but in my code checkbox are getting unchecked without removing the values in the text box, could anyone help me please. here Condition_Text__c , NCT01a_Date_Constraint__c ,NCT01b_Date_Constraint__c are long text area and NCT01_Date_Constraints__c is checkbox. one more thing is that for the 2 text valeus there is only one checkbox it should be unchecked when there is no value in the both text boxs, if anyone contain value it should be checked
trigger Update_Condition_Text on SCC__c (Before insert, Before update) {
String newConditionType='';
for(SCC__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT01a_Date_Constraint__c !='' && swCon.NCT01a_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c; //CH01.Old
system.debug('initial date check' + swCon.NCT01a_Date_Constraint__c);
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
system.debug('initial date check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=True;
system.debug('checkbox date check' + swCon.NCT01_Date_Constraints__c);
}
else
{
system.debug('Pleaes check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=false;
system.debug('what check' + swCon.NCT01_Date_Constraints__c);
}
if(swCon.NCT01b_Date_Constraint__c !='' && swCon.NCT01b_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c; //CH01.Old
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('@@@@@@' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
}
}
if(trigger.isUpdate)
{
if((swCon.NCT01a_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01a_Date_Constraint__c) && swCon.NCT01a_Date_Constraint__c != null && swCon.NCT01a_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c;//CH01.Old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('######' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('$$$$$$$$' + swCon.NCT01_Date_Constraints__c);
}
//CH01.New.End
if((swCon.NCT01b_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01b_Date_Constraint__c) && swCon.NCT01b_Date_Constraint__c != null && swCon.NCT01b_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c;//CH01.old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('!!!!!!!' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('&&&&&&&' + swCon.NCT01_Date_Constraints__c);
}
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
My requriment is that when i enter the values in the text box checkbox should be checked,if i remove the value in the text box , checkbox should be unchecked, but in my code checkbox are getting unchecked without removing the values in the text box, could anyone help me please. here Condition_Text__c , NCT01a_Date_Constraint__c ,NCT01b_Date_Constraint__c are long text area and NCT01_Date_Constraints__c is checkbox. one more thing is that for the 2 text valeus there is only one checkbox it should be unchecked when there is no value in the both text boxs, if anyone contain value it should be checked
trigger Update_Condition_Text on SCC__c (Before insert, Before update) {
String newConditionType='';
for(SCC__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT01a_Date_Constraint__c !='' && swCon.NCT01a_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c; //CH01.Old
system.debug('initial date check' + swCon.NCT01a_Date_Constraint__c);
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
system.debug('initial date check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=True;
system.debug('checkbox date check' + swCon.NCT01_Date_Constraints__c);
}
else
{
system.debug('Pleaes check' + swCon.NCT01_Date_Constraints__c);
swCon.NCT01_Date_Constraints__c=false;
system.debug('what check' + swCon.NCT01_Date_Constraints__c);
}
if(swCon.NCT01b_Date_Constraint__c !='' && swCon.NCT01b_Date_Constraint__c != null)
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c; //CH01.Old
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('@@@@@@' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
}
}
if(trigger.isUpdate)
{
if((swCon.NCT01a_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01a_Date_Constraint__c) && swCon.NCT01a_Date_Constraint__c != null && swCon.NCT01a_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01a Date Constraint: '+swCon.NCT01a_Date_Constraint__c;//CH01.Old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01a '+swCon.NCT01a_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('######' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('$$$$$$$$' + swCon.NCT01_Date_Constraints__c);
}
//CH01.New.End
if((swCon.NCT01b_Date_Constraint__c !=Trigger.oldMap.get(swCon.ID).NCT01b_Date_Constraint__c) && swCon.NCT01b_Date_Constraint__c != null && swCon.NCT01b_Date_Constraint__c !='')
{
//newConditionType = newConditionType + ', NCT01b Date Constraint: '+swCon.NCT01b_Date_Constraint__c;//CH01.old
//CH01.New.Start
newConditionType = newConditionType + ', NCT01b '+swCon.NCT01b_Date_Constraint__c;
swCon.NCT01_Date_Constraints__c=True;
system.debug('!!!!!!!' + swCon.NCT01_Date_Constraints__c);
}
else
{
swCon.NCT01_Date_Constraints__c=false;
system.debug('&&&&&&&' + swCon.NCT01_Date_Constraints__c);
}
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
- TheLearner
- December 06, 2015
- Like
- 0
Checkbox should be true, when i enter the value in the text box-- urgent
Hi Experts,
I have requirement that is If text is entered in field NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), on selecting Save button, check box field NCT04 Material & Plant Storage((NCT04_Material_Plant_Storage__c) should be true,
If text is removed/deleted from field the NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), corresponding chek box field is unchecked =(false). like this there are 11 text fields and 11 checkbox fields are there. Could you anyone help me please
I have requirement that is If text is entered in field NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), on selecting Save button, check box field NCT04 Material & Plant Storage((NCT04_Material_Plant_Storage__c) should be true,
If text is removed/deleted from field the NCT04b Material and Plant Storage(NCT04b_Material_and_Plant_Storage__c), corresponding chek box field is unchecked =(false). like this there are 11 text fields and 11 checkbox fields are there. Could you anyone help me please
- TheLearner
- December 02, 2015
- Like
- 0
New features on the forums!
Hi all! We've launched some new features here on the forums today - thanks to you all for your feedback on the new site! Here's today's update:
Best,
April
- New "Start a Discussion" button to make it easier for you to start a new thread (we still strongly encourage you to search the existing topics before you post though as it's very likely your topic has been addressed before!)
- Infinite scroll starts higher up on the page to provide a smoother experience
- Added a "Continue Reading" link on each discussion card
- Fixed a bug affecting the display of dates on some profile pages
- Fixes to how notifications are sent when you like or reply to posts
Best,
April
- thisisnotapril
- January 22, 2014
- Like
- 4
Need to Make a Change to Your Team?
We're getting many questions about how to add or drop someone from the team you registered with for the hackathon. Per the rules and regulations, you're allowed one change prior to teams locking on November 19th. If you'd like to make a change please email us at info@developerforce.com with the names of the team members you are adding or dropping. We'll need their names, email addresses, and registration number for Dreamforce - either from a Hacker Pass or a conference registration.
- thisisnotapril
- November 14, 2013
- Like
- 0
Question: How are 2nd-5th place winners paid out?
Winners will receive American Express gift cards payable in US Dollars.
- thisisnotapril
- October 25, 2013
- Like
- 1