• The new Learner
• NEWBIE
• 115 Points
• Member since 2015

• Chatter
Feed
• 0
• 2
• 0
Likes Given
• 41
Questions
• 70
Replies
HI Experts,

I am not getting exact hours by using below methd, can anyone help me please.
Verify Date - 2020/03/18 4:17 PM
Sent Date -2020/03/23 3:55 PM
above dates difference is 24 hours 8 minutes
but its showing as 23 hours 38 minutes.

```public static String duration_between_two_date_times(DateTime startDatetime, DateTime endDatetime)
{
Integer start_year_as_int = startDatetime.year(); //grab the start year
Integer start_day_as_int = startDatetime.dayOfYear(); //grab the start day
Integer start_hour_as_int = startDatetime.hour(); //grab the start hour
Integer start_minute_as_int = startDatetime.minute(); //grab the start minute
Integer start_second_as_int = startDatetime.second(); //grab the start second
Integer start_in_seconds = (start_year_as_int * 31556926) + (start_day_as_int * 86400) + (start_hour_as_int * 3600) + (start_minute_as_int * 60) + (start_second_as_int * 1); //convert the start date to a value in seconds
//there are 31556926 seconds in one year and that is why we are mutiplying the start_year_as_int value by 31556926 > this same logic applies to the days, hours & minutes logic which is why there are weird multipliers in that line of code
Integer end_year_as_int = endDatetime.year(); //grab the end year
Integer end_day_as_int = endDatetime.dayOfYear(); //grab the end day
Integer end_hour_as_int = endDatetime.hour(); //grab the end hour
Integer end_minute_as_int = endDatetime.minute(); //grab the end minute
Integer end_second_as_int = endDatetime.second(); //grab the end second
Integer end_in_seconds = (end_year_as_int * 31556926) + (end_day_as_int * 86400) + (end_hour_as_int * 3600) + (end_minute_as_int * 60) + (end_second_as_int * 1); //convert the end date to a value in seconds
Integer total_duration_in_seconds = end_in_seconds - start_in_seconds; //duration in seconds
Integer year_result = math.mod(math.floor(total_duration_in_seconds/31556926).intValue(),10000000); //number of years
Integer day_result = math.mod(math.floor(total_duration_in_seconds/86400).intValue(),365); //number of days
Integer hour_result = math.mod(math.floor(total_duration_in_seconds/3600).intValue(),24); //number of hours
Integer minute_result = math.mod(math.floor(total_duration_in_seconds/60).intValue(),60); //number of minutes
Integer second_result = math.mod(math.floor(total_duration_in_seconds/1).intValue(),60); //number of seconds
String shour= String.valueOf(hour_result );
String smint = String.valueOf(minute_result );
String shourmint=shour+'.'+smint;
return shourmint;

}

This Handler class code: which is before insert and before Update.

{
if(isWithinsent==true && isWithinclassify==true)
{

cs.Sent__c,cs.Verify_Date__c);
String strr=str.replace('-','');
cs.Verify_Hours__c=strr;```

How can i redirect to the contact page , once the opportunity record get created. can anyone help me please.

`/lightning/o/Opportunity/new?defaultFieldValues=Name={!Account.Name},ContactId={!Contact.Id}&backgroundContext=%2Flightning%2Fr%2FContact%2F{!Contact.Id}%2Fview`

Hi Experts,

I am not able to cover the code coverage for below else methods can anyone help me out, i have striked lines which i am not able to cover , till i can able to cover only 53% , please help me out.
```public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
{
List<Case> newCases = (List<Case>) newSobjs;
Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
for(Case cs : newCases)
{
Case oldCs = oldCasesMap.get(cs.Id);
Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
string oldCsstatus = oldCasesMap.get(cs.Id).Status;
string dayOfWeek=cs.lastmodifieddate.format('EEEE');
System.debug('Day : ' + dayOfWeek);
DateTime dT = cs.LastModifiedDate;
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
System.debug('myDate : ' + myDate );
String Mon ='Monday';
String Tue ='Tuesday';
String Wed ='Wednesday';
String Thur ='Thursday';
String Fri ='Friday';
String Sat= 'Saturday';
String Sun= 'Sunday';

if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
{
if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Sent_Formula__c;
system.debug('mydecvalmydecvalmydecval'+mydecval);
Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
system.debug('myintvalmyintvalmyintval'+myintval);

myintval,
}

else if (dayOfWeek == Mon)
{
cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

}

}

{
get
{
{
}
}
set;
}
}```
Below is my test class :

```Public static testMethod void Case_Test_method1()
{

Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get(' L - QNA').getRecordTypeId();
Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();

BusinessHours bhs=[SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];
Boolean isWithin = BusinessHours.isWithin(bhs.id, datetime.newInstance(2020, 03, 09, 05, 30, 0));
//System.assert(bhs.size()==1);
if(isWithin==false)
{
case c1 = new case();
c1.Origin='email';
c1.Status='Assigned';
c1.RecordtypeId= recordtyepe;
c1.Process__c='Verify';
c1.Process__c= 'Preparation';
insert c1;

//c1.Sent_to_Prepare_Quote_Hours__c=hours;
c1.Status='Quote Completed and Emailed to Broker';
c1.Process__c='Quote Preparation';
c1.Process__c='Classify/Verify';
c1.RecordtypeId =recordtyepes;
c1.Sent_to__c= system.now();
try{
update c1;
}
catch(exception e){}
}
}
}```

Hi Experts,

I am not Not able to cover the below class handler which works before update , can anyone help me out. please. still its only 53%, majority of the issue is wiht else part which i bolded.

```public without sharing class Stamp_Case
{

public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
{
List<Case> newCases = (List<Case>) newSobjs;
Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
for(Case cs : newCases)
{
Case oldCs = oldCasesMap.get(cs.Id);
Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
string oldCsstatus = oldCasesMap.get(cs.Id).Status;
string dayOfWeek=cs.lastmodifieddate.format('EEEE');
System.debug('Day : ' + dayOfWeek);
DateTime dT = cs.LastModifiedDate;
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
System.debug('myDate : ' + myDate );
String Mon ='Monday';
String Tue ='Tuesday';
String Wed ='Wednesday';
String Thur ='Thursday';
String Fri ='Friday';
String Sat= 'Saturday';
String Sun= 'Sunday';

if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
{
if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Sent_Formula__c;
system.debug('mydecvalmydecvalmydecval'+mydecval);
Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
system.debug('myintvalmyintvalmyintval'+myintval);

myintval,
}

**else if (dayOfWeek == Mon)
{
cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

if((cs.status =='Emailed to Broker' || cs.status==' Emailed to Distribution') && oldCsstatus != cs.status)
{
**if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{
cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Dist_Formula__c;

Integer myintval = mydecval.intValue();
system.debug('myintvalmyintvalmyintval'+myintval);
myintval,
}
else if (dayOfWeek == Mon)
{
cs.Dist__c= DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Dist__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Dist__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;
}**

}

if(cs.Process__c=='Verify' && cs.Verify_Date__c== null)
{

if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Date_Formula__c;

Integer myintval = mydecval.intValue();

myintval,
}

**else if (dayOfWeek == Mon)
{
cs.Verify_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Verify_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Verify_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

if(cs.Process__c=='Preparation' && cs.Preparation_Date__c== null)
{

if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Preparation_Date_Formula__c;

Integer myintval = mydecval.intValue();

myintval,

}

else if (dayOfWeek == Mon)
{
**cs.Preparation_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);**
}
else if(dayOfWeek == Tue)
{
**cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;**
}
else if(dayOfWeek == Wed)
{
**cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;**
}
else if(dayOfWeek == Thur)
{
cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
**else if(dayOfWeek == Fri)
{
cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Preparation_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Preparation_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

}

}

{
get
{
{
}
}
set;
}
}

Below is my Test class.

@isTest
public class Case_Test{

Public static testMethod void Test_method()
{

Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get('- L - QNA').getRecordTypeId();
Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();

case c = new case();
c.Origin='email';
c.Status='Assigned';
c.RecordtypeId= recordtyepe;
c.Process__c='Verify';
c.Process__c= 'Preparation';
insert c;
c.Process__c='Preparation';
c.Process__c='Verify';
c.RecordtypeId =recordtyepes;
Test.setCreatedDate(c.Id,  datetime.newInstance(2019, 11, 11, 11, 30, 0));
Test.startTest();
case cs= [SELECT Id, CreatedDate,LastModifiedDate FROM case  where origin='email' limit 1];
System.assertEquals(cs.CreatedDate,  DateTime.newInstance(2019,11,11,11,30,0));
Test.stopTest();
update c;

}
}```

Hi Experts,

I have requirment i need create a button(not java script button because i cant use in lighting) when i click on that button new record page has to open and also i want set a default value in that new record page, can anyone hlep me please.
Hi Experts,

I am trying to update the State and Country ISO Code picklist values using packages but i am getting below error while deploying using workbench. can anyone tell me how to update it please

here is the package:

<?xml version="1.0" encoding="UTF-8"?>
<types>
<name>Settings</name>
</types>
<version>42.0</version>
</Package>

Error:
Invalid iso code AB for country Aruba
Hi Experts,

Can anyone help me how to write test class for the below method.

public override void onCommit(){

OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
Map<String, List<SObject>> accObjects =  OM_WorkService.getSObjects(accJSON);
Account acc = (Account)accObjects.get('Account')[0];

if(acc!= null){
upsert acc;
super.onCommit();

}

Below is the OM_WorkService.getJSONAttribut

public static String getJSONAttribute(String jsonStr, String attr){
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
if(m.containsKey(attr))
return (String)m.get(attr);

return null;
}

Hi Experts,

Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
Hi Experts,

We have requirment where we need to replace Opportunity Proudct with the standard object oportunity product object, so i have edited entire controller code
but problem here is that when i replace stadnardcontroller with the OpportunityLineItem in the visualforce page its not allowing me to work its throwing an error called "Error: List controllers are not supported for OpportunityLineItem    ",
can anyone help me out, how to fix this issue.

```Vf page:
<apex:page standardController="Product__c" recordSetVar="oppProds" extensions="ProductController" showHeader="false" standardStylesheets="true" sidebar="false"
docType="html-5.0">

<body>
<apex:form id="frm">
<div align="center">
<div class="h1Div" >
<input type="button" id="btnBack1" value="Back" class="sf1buttonSFBlue backButtonControlClass" onClick="javascript: goBack();" style="float: left;margin-top: -5px;margin-right: 15px;height: 35px;"/>
<h1>Opportunity Products</h1>
</div>
<br/>
<apex:pageMessages id="MESSAGES"/>
</div>

<div class="sf1divBlock">
<apex:outputLabel value="{!cOpp.Name}" style="margin-left: 5px;"/>
</div>
<br/>
<apex:outputPanel id="OPPPRODPANEL">
<table id="OPPPRODTABLE" class="sf1Table" style="width:100%;">
<tr>
<th width="50%"> Product </th>
<th width="12%"> Include in next quote </th>
<th width="22.5%"> Quantity </th>
<th width="22.5%"> Requested Price </th>
<th class="DMLActions" width="5%"> Action </th>
</tr>
<tbody>
<apex:variable var="rowClass" value="odd"/>
<apex:variable var="rowNum" value="{!0}"/>
<apex:repeat value="{!clstOppProds}" var="oppProd">
<tr class="{!rowClass}">
<td>
<input type="text" id="prodName{!rowNum}" name="prodName{!rowNum}" class="sf1Input"/>
</div>
<script>
var prodName{!rowNum} = jQuery('#prodName{!rowNum}');
if(prodName{!rowNum}){
{
minLength: 3,
highlight: true
},
{
limit: 999,
display: 'value',
source: function(searchText, syncCallback, asyncCallback) {
searchText = searchText.split('\\').join('\\\\');
searchText = searchText.split('\'').join('\\\'');
var sObj = new SObjectModel.Product2();
sObj.retrieve({
where:{
or:{
Name: {like: searchText + '%'},
or:{
Description: {like: searchText + '%'},
Product2: {like : searchText + '%'}
}
},
and:{
Active__c: {eq: true},
or:{
RecordTypeId: {eq: '{!ProductRTId}'},
and:{
Status__c: {eq: 'Approved'},
Product__c: {eq: ''}
}
}
}
},
orderby: [{Name: 'ASC'}],
limit:999},
function(err,records){
if(err){
} else {
var dataList = [];
var maxLength = 1;
jQuery.each(records, function(index, record){
dataList.push({
id: record.get('Id'),
value: jQuery('<div/>').html(record.get('Name')).text(),
code: jQuery('<div/>').html(record.get('Type_Code__c')).text(),
desc2: jQuery('<div/>').html(record.get('Description')).text()
});
});
asyncCallback(dataList);
}
}
)
},
templates: {
suggestion: function (data) {
var desc = data.value;
if(data.desc2) desc += ' - ' + data.desc2;
return '<div><table class="tt-table"><tr><td class="tt-table-td1">' + desc + '</td><td class="tt-table-td2">' + data.code + '</td></tr></table></div>';
}
}
}
setProd({!rowNum},datum.id,datum.value);
setProd({!rowNum},datum.id,datum.value);
//Reset the fields to blank

});
}
</script>
</td>

<td>
<apex:inputField value="{!oppProd.Next_Quote__c}" style="width:30px; height:20px;"/>
</td>
<td>
<apex:inputField value="{!oppProd.Quantity__c}" styleClass="sf1Input"/>
</td>
<td>
<apex:inputField value="{!oppProd.Price__c}" styleClass="sf1Input"/>
</td>
<td valign="top" class="DMLActions">
<input type="button" id="btnDelete{!oppProd.id}" class="sf1buttonDelete" value="" onClick="removeRow('{!rowNum}');" />
</td>
</tr>
<apex:variable var="rowClass" value="{!IF(rowClass == 'odd','','odd')}"/>
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
<table class="sf1InputTableTwoCol">
<tr>
<td>
<input type="button" id="btnBack" class="sf1buttonSFBlue" value="Back" onClick="goBack();" />
<input type="button" id="btnSave" class="sf1buttonSFBlue" value="Save" onClick="doSave();" />
</td>
</tr>
</table>
</div>

<apex:actionFunction name="setProd" action="{!setProd}" reRender="MESSAGES" status="status">
<apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
<apex:param name="p2" value="" assignTo="{!selectedRowProdId}"/>
<apex:param name="p3" value="" assignTo="{!selectedRowProdName}"/>
</apex:actionFunction>
<apex:actionFunction name="removeRow" action="{!removeRow}" reRender="MESSAGES,OPPPRODPANEL" status="status">
<apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
</apex:actionFunction>
<apex:actionFunction name="goBack" action="{!cancel}" reRender="MESSAGES" status="status"/>
<apex:actionFunction name="doSave" action="{!doSave}" reRender="MESSAGES" status="status"/>

<apex:actionstatus id="status">
<apex:facet name="start">
<div class="waitingHolder" style="top:220px;">
</div>
</div>
</apex:facet>
</apex:actionstatus>
</apex:form>
</body>
</apex:page>

Apex class:

public class ProductController {
public Opportunity cOpp {get;set;}
public Integer selectedRowNum {get;set;}
public String selectedRowProdId {get;set;}
public String selectedRowProdName {get;set;}
public List<OpportunityLineItem> clstOppProds {get;set;}
public List<OpportunityLineItem> clstDelOppProds {get;set;}
public String getJDEProductRTId(){
return [SELECT Id FROM RecordType WHERE SObjectType = 'Product2' AND Name = 'New Products' LIMIT 1].get(0).Id;
}

public ProductController(ApexPages.StandardSetController ssc) {
selectedRowNum = null;
selectedRowProdId = null;
selectedRowProdName = null;
String oppId = ApexPages.currentPage().getParameters().get('id');
cOpp = null;
for(Opportunity o : [SELECT Id,Name FROM Opportunity WHERE Id = :oppId]) cOpp = o;
clstOppProds = new List<OpportunityLineItem>();
clstDelOppProds = new List<OpportunityLineItem>();
if(oppId != null) clstOppProds = [SELECT Id,Opportunityid,Next_Quote__c,Product2id,Product2.Name,Quantity__c,Price__c FROM OpportunityLineItem WHERE Opportunityid = :oppId];
}

public PageReference setProd(){
PageReference pg = null;
OpportunityLineItem op = clstOppProds.get(selectedRowNum);
Product2 pt = new Product2(id=selectedRowProdId,name=selectedRowProdName);
op.Product2id = selectedRowProdId;
op.Product2.Name = pt.Name;
return pg;
}

public PageReference removeRow(){
PageReference pg = null;
OpportunityLineItem op = clstOppProds.remove(selectedRowNum);
return pg;
}

PageReference pg = null;
return pg;
}
public PageReference doSave(){
PageReference pg = null;
SavePoint sp = Database.setSavePoint();
try{
delete clstDelOppProds;
upsert clstOppProds;
pg = new PageReference('/'+cOpp.Id);
}catch(Exception e){
Database.rollback(sp);
}
return pg;
}
}```

Hi Experts,

I have small requirement where i need to filter a long text area field called Desc__c which i am not able to do that can anyone help me please.

OrderItem oli1 = new OrderItem ();
oli1.Orderid = order.Id;
oli1.Desc__c= 'Test OLI 1';
insert oli1;

OrderItem oli2 = [SELECT Id, Orderid
FROM OrderItem WHERE  Desc__c = 'Test OLI 1' LIMIT 1];

In this filter condition its throwing an error can anyone help me please thanks in adavance
Hi Experts,

Can anyone helps me , while running my test class i am getting below error. Below is my code anyone help  me please. the area which i made bold in the insert command i receiving this can anyone helps me please.

DUPLICATE_VALUE, This price definition already exists in this price book: []

Account a = new Account(Name='testAccount',RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId()); //Added by Purnima for Story S-562343
insert a;

Id pricebookId = Test.getStandardPricebookId();

Product2 prod = new Product2(Name = 'Laptop X200',
Family = 'Hardware');
insert prod;

/*PricebookEntry standardPrice = new PricebookEntry(
Pricebook2Id = pricebookId, Product2Id = prod.Id,
UnitPrice = 10000, IsActive = true);
insert standardPrice;*/

PriceBookEntry stdPriceBookEntry = new PriceBookEntry();
stdPriceBookEntry.Product2Id=prod.Id;
stdPriceBookEntry.Pricebook2Id=pricebookId;
stdPriceBookEntry.UnitPrice=2000;
stdPriceBookEntry.IsActive=true;
insert stdPriceBookEntry;

Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
insert customPB;

PricebookEntry customPrice = new PricebookEntry(
Pricebook2Id = customPB.Id, Product2Id = prod.Id,
UnitPrice = 12000, IsActive = true);
insert customPrice;
Product_Type__c productType = new Product_Type__c();
productType.Product_Type_Code__c = 'End';

insert productType;

Opportunity opp = new Opportunity(Name='Test',
Account = a,
// Product__c='GRI Retail',
NextStep='test',
PriceBook2 = customPB,
CloseDate = System.today(),
AccountId=a.Id,
// Opportunity_Name__c='testOpp',
// Product_Family__c='Retail',
Industry__c='Other',
Description='TestTestTest',
StageName='Closed Won - One Time'
);

insert opp;

List<Opportunity_Product__c> oppProdList = new List<Opportunity_Product__c>();
for(Integer i=1;i<=10;i++)
oppProdList.add(new Opportunity_Product__c (Opportunity__c = opp.Id,Product__c = productType.id));

System.debug('test@@@'+ oppProdList );

insert oppProdList;

ApexPages.StandardSetController sc = new ApexPages.StandardSetController(oppProdList);

PageReference pageRef = Page.OpportunityProducts;
pageRef.getParameters().put('id', String.valueOf(''));
Test.setCurrentPage(pageRef);

//Test.setCurrentPageReference(Page.OpportunityProducts);

OpportunityController obj= new OpportunityController(sc);
obj.selectedRowNum=1;
obj.selectedRowProdId=productType.id;
obj.selectedRowProdName=productType.Name;
obj.cOpp=opp;
List<Opportunity_Product__c> testopp= new List<Opportunity_Product__c>();
obj.clstOppProds=oppProdList;
List<Opportunity_Product__c> testOpps= new  List<Opportunity_Product__c>();
obj.clstDelOppProds=oppProdList;

obj.getJDEProductRTId();

//Product_Type__c pt = new Product_Type__c(id='test', name='test');
System.debug('clstOppProds==>' + obj.clstOppProds);
System.debug('clstDelOppProds==>' + obj.clstDelOppProds);

PageReference pg = obj.doSave();
//PageReference pg3 = obj.setProd();
PageReference pg2 = obj.removeRow();

Hi Experts,
I wrote one batch class with contractor like below. but when i was try to run my test class i am getting an error that constructor is not defind. below is my test class as well , can anyone help me plesae . thanks in advance
private  list<String> sOrganization;
public UpdateAccountCallList(String[] sorg) {
sOrganization = sorg;
}

Test class:

@isTest
public class AccountUpdatecallistBatchJobTest
{
static testMethod void testMethod1()
{
List<Account> lstAccount= new List<Account>();
List<Account> lstAccount1= new List<Account>();
List<Account> lstAccount2= new List<Account>();
List<Account> lstAccount3= new List<Account>();
List<Account> lstAccount4= new List<Account>();
List<Account> lstAccount5= new List<Account>();
for(Integer i=0 ;i <5;i++)
{
Account acc = new Account();
acc.Name =’Name’+i;
acc.Call_List_Frequency__c=8;
acc.Call_List__c=true;
acc.Call_List_Start_Date__c=system.today()-1;
acc.Call_List_Preferred_Day__c=’MOnday’;
date myDate = date.today();
acc.Call_List_Next_Preferred_Date__c=myDate.toStartofWeek()+0;
Account acc1 = new Account();
acc1.Name =’Name1’+i;
acc1.Call_List_Frequency__c=6.0;
acc1.Call_List__c=true;
acc1.Call_List_Start_Date__c=system.today()-1;
acc1.Call_List_Preferred_Day__c=’Tuesday’;
date myDate1 = date.today();
acc1.Call_List_Next_Preferred_Date__c=myDate1.toStartofWeek()+1;
Account acc2 = new Account();
acc2.Name =’Name1’+i;
acc2.Call_List_Frequency__c=6.0;
acc2.Call_List__c=true;
acc2.Call_List_Start_Date__c=system.today()+1;
acc2.Call_List_Preferred_Day__c=’Wednesday’;
date myDate2 = date.today();
acc2.Call_List_Next_Preferred_Date__c=myDate2.toStartofWeek()+2;
Account acc3 = new Account();
acc3.Name =’Name1’+i;
acc3.Call_List_Frequency__c=6.0;
acc3.Call_List__c=true;
acc3.Call_List_Start_Date__c=system.today()-1;
acc3.Call_List_Preferred_Day__c=’Thursday’;
date myDate3 = date.today();
acc3.Call_List_Next_Preferred_Date__c=myDate3.toStartofWeek()+3;
Account acc4 = new Account();
acc4.Name =’Name1’+i;
acc4.Call_List_Frequency__c=6.0;
acc4.Call_List__c=true;
acc4.Call_List_Start_Date__c=system.today()-1;
acc4.Call_List_Preferred_Day__c=’Friday’;
date myDate4 = date.today();
acc4.Call_List_Next_Preferred_Date__c=myDate4.toStartofWeek()+4;
Account acc5 = new Account();
acc5.Name =’Name1’+i;
acc5.Call_List_Frequency__c=6.0;
acc5.Call_List__c=true;
acc5.Call_List_Start_Date__c=system.today()-1;
acc5.Call_List_Preferred_Day__c=’None’;
acc5.Call_List_Next_Preferred_Date__c=system.today();
}
insert lstAccount;
insert lstAccount1;
insert lstAccount2;
insert lstAccount3;
insert lstAccount4;
insert lstAccount5;
Test.startTest();
UpdateAccountCallList obj = new UpdateAccountCallList();
obj.currentweek=9;
DataBase.executeBatch(obj);
Test.stopTest();
}
}
Hi Experts,

I have requirement i need to update the task owner once lead owner changes for me its working but getting too many soql errors when i chek debug log i am getting lot of records including my record , can anyone help me please, my trigger is after insert and after update which is on lead object.

{
system.debug('++++tsk'+tsk);
system.debug('++++owner'+owner);
system.debug('++++test'+test);
{
system.debug('++++owners'+tsk.ownerid);
}
}

HI Experts,

I am new to Lighting , i have requirment i need to update Account fields by creating button ,  i have created component and helper and controller its working fine when i pass id in my controller but i need to make my code dyanmic means what ever account record i pick randomly that account field has to update. can anyone help me pls below is my code. Thanks in advace

Component :

<!--<aura:attribute name="updateCheckBox" type="Account" default="{'sobjectType':'Account'}"/>-->
<lightning:button variant="brand" label="Update A Checkbox" onclick="{!c.updateCheck11}"  />
</aura:component>

Controller :

({
updateCheck11  : function(component, event, helper) {
helper.updateCheck11_helper(component, event, helper);
}
})

Helper :
({
updateCheck11_helper  : function(component, event, helper) {
var save_action = component.get("c.updateCheck");
save_action.setParams({ });
\$A.enqueueAction(save_action);

}
})

Apex controller:

public class AccountFieldupdats {
@AuraEnabled
public static void updateCheck(){
list<Account> Act_list = new list<Account>();
Act_list = [select id,Call_List__c from Account where id=''];
Account ACC =new Account();
ACC.id=Act_list[0].id;
ACC.Call_List__c=False;
update ACC;

}
}
Hi Experts,

Below is my code and i am new lighting , i have created a custom visualforce button its working fine in classic but its not working in lighting and also after clicking on that button its showing some black page , it has show to the same record page, can anyone help me pls. below is my code.
and my button behaviour is "BehaviorDisplay in existing window without sidebar or header"

<apex:page standardController="Account">
<apex:includeScript value="../../soap/ajax/23.0/connection.js"/>
<script>
sforce.connection.sessionId='{!GETSESSIONID()}';
var url = parent.location.href;
var updateRecords = [];
var update_account = new sforce.SObject("Account");
update_account.id = "{!Account.Id}";
update_account.List__c = "False";
updateRecords.push(update_account);

result = sforce.connection.update(updateRecords);
if (result[0].success=="true"){
if(typeof sforce !== 'undefined') {
sforce.one.back(true);

} else {
window.location.href = document.referrer;
}
}
else
</script>
</apex:page>
Hi Experts,

I have below code which is calling before update on account ,i have nested loops because of that i am getting cpu time out issue, can anyone convert my code into MAp please.

Set<Id> Accids= New Set<Id>();
Set<String>Fun= new set<string>();

Id AccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('RecordType').getRecordTypeId();

if(AccRecordTypeId !=null)
{
FOR(Account A : newList)
{

if(A.RecordTypeId == AccRecordTypeId)
{
system.debug('%%%%%%'+Accids);
}

}

}
String samp = System.Label.User_ID;
List<Function__c> PR = [Select Id,Salesforce_ID__c,Function_Def__c,Person__c,Pernr__c from Function__c where Salesforce_ID__c IN : Accids and Pernr__c !=null ];
system.debug('\$\$\$\$\$\$'+PR );

for(Function__c pf: PR)
{
if( pf.Salesforce_ID__c != Null)
{
system.debug('^^^^^^'+pf);
system.debug('#######'+Fun);
}
}

list<Person__c> gp = [ select id , Employee_ID__c,User__c,OwnerId from Person__c where Employee_ID__c in : Fun];
system.debug('@@@@@'+gp );

if(gp.size()>0)
{

FOR(Account A : newList)

{

for(Person__c gpr: gp)
{
for( Function__c pfr: PR)
{
if(gpr.User__c!=null && pfr.Function_Def__c!=null )
{

if(pfr.Function_Def__c== 'ABC' )
{

system.debug('&&&&&'+gpr);
A.OwnerId=gpr.User__c;
system.debug('!!!!!'+A.ownerid);

}
else if(pfr.Function_Def__c== 'DEF' || pfr.Function_Def__c== 'GHI' || pfr.Function_Def__c== 'JKL')
{
A.OwnerId=gpr.User__c;
system.debug('88888'+A.ownerid);

}
}
else
{
A.OwnerId=samp;
system.debug('***'+A.ownerid);
}
}
}
}

}
HI Experts,

I am new to lighitng, can i have code how to write button on account when i click that account i need one field to be disabled. ex: checkbox should be false.

I have two fields called Week and Frequency of deciaml with place 0, now my requirment is if  Week/Frequency out put with decimal zero then it need to allow in the loop. Excpet Zero(eg:1.0,2.0,3.0) in the deciamal place it should not allow any value (eg:1.1,2.1,3.1) .

Eg:
Week=42.0, freuency=6.0
currentweek=week/freuency;
currentweek=7.0 then i need to make checkbox true
if currentweek value is 7.1 then i need to make that checkbox false
Hi Experts,

I need to calculate two fieds which are decimals of place  0(1,0). now my requriment is that when Week__c/frequency__c output is 1.0,2.0 it should allow only 0 decimal place if not it should not allow in the loop. eg:output is 6.0 it should allow in the loop if the output is 6.1 it should not. can anyone help me pls.
Hi Experts,

Below is the formula field which i need o cover the in the test class but i am not able to do that kindly help me out.
Current_Week__c is formula field  which we have (IF(
CEILING( (TODAY() - DATE ( YEAR(TODAY()), 1, 1) + 1) / 7) > 52,
52,
CEILING( (TODAY() - DATE( YEAR(TODAY()), 1, 1) + 1) / 7)
))
below is calculation which i am doing in the class.
decimal currentweek=a.Current_Week__c/a.Call_List_Frequency__c;
if(currentweek.scale()<0)

Hi Experts,

Can anyone help me how to write test class for the below method.

public override void onCommit(){

OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
Map<String, List<SObject>> accObjects =  OM_WorkService.getSObjects(accJSON);
Account acc = (Account)accObjects.get('Account')[0];

if(acc!= null){
upsert acc;
super.onCommit();

}

Below is the OM_WorkService.getJSONAttribut

public static String getJSONAttribute(String jsonStr, String attr){
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
if(m.containsKey(attr))
return (String)m.get(attr);

return null;
}

How can i redirect to the contact page , once the opportunity record get created. can anyone help me please.

`/lightning/o/Opportunity/new?defaultFieldValues=Name={!Account.Name},ContactId={!Contact.Id}&backgroundContext=%2Flightning%2Fr%2FContact%2F{!Contact.Id}%2Fview`

Hi Experts,

I am not Not able to cover the below class handler which works before update , can anyone help me out. please. still its only 53%, majority of the issue is wiht else part which i bolded.

```public without sharing class Stamp_Case
{

public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
{
List<Case> newCases = (List<Case>) newSobjs;
Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
for(Case cs : newCases)
{
Case oldCs = oldCasesMap.get(cs.Id);
Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
string oldCsstatus = oldCasesMap.get(cs.Id).Status;
string dayOfWeek=cs.lastmodifieddate.format('EEEE');
System.debug('Day : ' + dayOfWeek);
DateTime dT = cs.LastModifiedDate;
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
System.debug('myDate : ' + myDate );
String Mon ='Monday';
String Tue ='Tuesday';
String Wed ='Wednesday';
String Thur ='Thursday';
String Fri ='Friday';
String Sat= 'Saturday';
String Sun= 'Sunday';

if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
{
if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Sent_Formula__c;
system.debug('mydecvalmydecvalmydecval'+mydecval);
Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
system.debug('myintvalmyintvalmyintval'+myintval);

myintval,
}

**else if (dayOfWeek == Mon)
{
cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

if((cs.status =='Emailed to Broker' || cs.status==' Emailed to Distribution') && oldCsstatus != cs.status)
{
**if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{
cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Dist_Formula__c;

Integer myintval = mydecval.intValue();
system.debug('myintvalmyintvalmyintval'+myintval);
myintval,
}
else if (dayOfWeek == Mon)
{
cs.Dist__c= DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Dist__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Dist__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Dist__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;
}**

}

if(cs.Process__c=='Verify' && cs.Verify_Date__c== null)
{

if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Date_Formula__c;

Integer myintval = mydecval.intValue();

myintval,
}

**else if (dayOfWeek == Mon)
{
cs.Verify_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);
}
else if(dayOfWeek == Tue)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
}
else if(dayOfWeek == Wed)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
}
else if(dayOfWeek == Thur)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
else if(dayOfWeek == Fri)
{
cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Verify_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Verify_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

if(cs.Process__c=='Preparation' && cs.Preparation_Date__c== null)
{

if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
{

cs.CreatedDate,
cs.LastModifiedDate,

Decimal mydecval = cs.Preparation_Date_Formula__c;

Integer myintval = mydecval.intValue();

myintval,

}

else if (dayOfWeek == Mon)
{
**cs.Preparation_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);**
}
else if(dayOfWeek == Tue)
{
**cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;**
}
else if(dayOfWeek == Wed)
{
**cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;**
}
else if(dayOfWeek == Thur)
{
cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;

}
**else if(dayOfWeek == Fri)
{
cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sat)
{
Date satdate = myDate- 1;
cs.Preparation_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
}
else if(dayOfWeek == Sun)
{
Date Sundate=myDate- 2;
cs.Preparation_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
}

}

}

}

{
get
{
{
}
}
set;
}
}

Below is my Test class.

@isTest
public class Case_Test{

Public static testMethod void Test_method()
{

Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get('- L - QNA').getRecordTypeId();
Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();

case c = new case();
c.Origin='email';
c.Status='Assigned';
c.RecordtypeId= recordtyepe;
c.Process__c='Verify';
c.Process__c= 'Preparation';
insert c;
c.Process__c='Preparation';
c.Process__c='Verify';
c.RecordtypeId =recordtyepes;
Test.setCreatedDate(c.Id,  datetime.newInstance(2019, 11, 11, 11, 30, 0));
Test.startTest();
case cs= [SELECT Id, CreatedDate,LastModifiedDate FROM case  where origin='email' limit 1];
System.assertEquals(cs.CreatedDate,  DateTime.newInstance(2019,11,11,11,30,0));
Test.stopTest();
update c;

}
}```

Hi Experts,

I have requirment i need create a button(not java script button because i cant use in lighting) when i click on that button new record page has to open and also i want set a default value in that new record page, can anyone hlep me please.
Hi Experts,

Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
Hi Experts,

We have requirment where we need to replace Opportunity Proudct with the standard object oportunity product object, so i have edited entire controller code
but problem here is that when i replace stadnardcontroller with the OpportunityLineItem in the visualforce page its not allowing me to work its throwing an error called "Error: List controllers are not supported for OpportunityLineItem    ",
can anyone help me out, how to fix this issue.

```Vf page:
<apex:page standardController="Product__c" recordSetVar="oppProds" extensions="ProductController" showHeader="false" standardStylesheets="true" sidebar="false"
docType="html-5.0">

<body>
<apex:form id="frm">
<div align="center">
<div class="h1Div" >
<input type="button" id="btnBack1" value="Back" class="sf1buttonSFBlue backButtonControlClass" onClick="javascript: goBack();" style="float: left;margin-top: -5px;margin-right: 15px;height: 35px;"/>
<h1>Opportunity Products</h1>
</div>
<br/>
<apex:pageMessages id="MESSAGES"/>
</div>

<div class="sf1divBlock">
<apex:outputLabel value="{!cOpp.Name}" style="margin-left: 5px;"/>
</div>
<br/>
<apex:outputPanel id="OPPPRODPANEL">
<table id="OPPPRODTABLE" class="sf1Table" style="width:100%;">
<tr>
<th width="50%"> Product </th>
<th width="12%"> Include in next quote </th>
<th width="22.5%"> Quantity </th>
<th width="22.5%"> Requested Price </th>
<th class="DMLActions" width="5%"> Action </th>
</tr>
<tbody>
<apex:variable var="rowClass" value="odd"/>
<apex:variable var="rowNum" value="{!0}"/>
<apex:repeat value="{!clstOppProds}" var="oppProd">
<tr class="{!rowClass}">
<td>
<input type="text" id="prodName{!rowNum}" name="prodName{!rowNum}" class="sf1Input"/>
</div>
<script>
var prodName{!rowNum} = jQuery('#prodName{!rowNum}');
if(prodName{!rowNum}){
{
minLength: 3,
highlight: true
},
{
limit: 999,
display: 'value',
source: function(searchText, syncCallback, asyncCallback) {
searchText = searchText.split('\\').join('\\\\');
searchText = searchText.split('\'').join('\\\'');
var sObj = new SObjectModel.Product2();
sObj.retrieve({
where:{
or:{
Name: {like: searchText + '%'},
or:{
Description: {like: searchText + '%'},
Product2: {like : searchText + '%'}
}
},
and:{
Active__c: {eq: true},
or:{
RecordTypeId: {eq: '{!ProductRTId}'},
and:{
Status__c: {eq: 'Approved'},
Product__c: {eq: ''}
}
}
}
},
orderby: [{Name: 'ASC'}],
limit:999},
function(err,records){
if(err){
} else {
var dataList = [];
var maxLength = 1;
jQuery.each(records, function(index, record){
dataList.push({
id: record.get('Id'),
value: jQuery('<div/>').html(record.get('Name')).text(),
code: jQuery('<div/>').html(record.get('Type_Code__c')).text(),
desc2: jQuery('<div/>').html(record.get('Description')).text()
});
});
asyncCallback(dataList);
}
}
)
},
templates: {
suggestion: function (data) {
var desc = data.value;
if(data.desc2) desc += ' - ' + data.desc2;
return '<div><table class="tt-table"><tr><td class="tt-table-td1">' + desc + '</td><td class="tt-table-td2">' + data.code + '</td></tr></table></div>';
}
}
}
setProd({!rowNum},datum.id,datum.value);
setProd({!rowNum},datum.id,datum.value);
//Reset the fields to blank

});
}
</script>
</td>

<td>
<apex:inputField value="{!oppProd.Next_Quote__c}" style="width:30px; height:20px;"/>
</td>
<td>
<apex:inputField value="{!oppProd.Quantity__c}" styleClass="sf1Input"/>
</td>
<td>
<apex:inputField value="{!oppProd.Price__c}" styleClass="sf1Input"/>
</td>
<td valign="top" class="DMLActions">
<input type="button" id="btnDelete{!oppProd.id}" class="sf1buttonDelete" value="" onClick="removeRow('{!rowNum}');" />
</td>
</tr>
<apex:variable var="rowClass" value="{!IF(rowClass == 'odd','','odd')}"/>
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
<table class="sf1InputTableTwoCol">
<tr>
<td>
<input type="button" id="btnBack" class="sf1buttonSFBlue" value="Back" onClick="goBack();" />
<input type="button" id="btnSave" class="sf1buttonSFBlue" value="Save" onClick="doSave();" />
</td>
</tr>
</table>
</div>

<apex:actionFunction name="setProd" action="{!setProd}" reRender="MESSAGES" status="status">
<apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
<apex:param name="p2" value="" assignTo="{!selectedRowProdId}"/>
<apex:param name="p3" value="" assignTo="{!selectedRowProdName}"/>
</apex:actionFunction>
<apex:actionFunction name="removeRow" action="{!removeRow}" reRender="MESSAGES,OPPPRODPANEL" status="status">
<apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
</apex:actionFunction>
<apex:actionFunction name="goBack" action="{!cancel}" reRender="MESSAGES" status="status"/>
<apex:actionFunction name="doSave" action="{!doSave}" reRender="MESSAGES" status="status"/>

<apex:actionstatus id="status">
<apex:facet name="start">
<div class="waitingHolder" style="top:220px;">
</div>
</div>
</apex:facet>
</apex:actionstatus>
</apex:form>
</body>
</apex:page>

Apex class:

public class ProductController {
public Opportunity cOpp {get;set;}
public Integer selectedRowNum {get;set;}
public String selectedRowProdId {get;set;}
public String selectedRowProdName {get;set;}
public List<OpportunityLineItem> clstOppProds {get;set;}
public List<OpportunityLineItem> clstDelOppProds {get;set;}
public String getJDEProductRTId(){
return [SELECT Id FROM RecordType WHERE SObjectType = 'Product2' AND Name = 'New Products' LIMIT 1].get(0).Id;
}

public ProductController(ApexPages.StandardSetController ssc) {
selectedRowNum = null;
selectedRowProdId = null;
selectedRowProdName = null;
String oppId = ApexPages.currentPage().getParameters().get('id');
cOpp = null;
for(Opportunity o : [SELECT Id,Name FROM Opportunity WHERE Id = :oppId]) cOpp = o;
clstOppProds = new List<OpportunityLineItem>();
clstDelOppProds = new List<OpportunityLineItem>();
if(oppId != null) clstOppProds = [SELECT Id,Opportunityid,Next_Quote__c,Product2id,Product2.Name,Quantity__c,Price__c FROM OpportunityLineItem WHERE Opportunityid = :oppId];
}

public PageReference setProd(){
PageReference pg = null;
OpportunityLineItem op = clstOppProds.get(selectedRowNum);
Product2 pt = new Product2(id=selectedRowProdId,name=selectedRowProdName);
op.Product2id = selectedRowProdId;
op.Product2.Name = pt.Name;
return pg;
}

public PageReference removeRow(){
PageReference pg = null;
OpportunityLineItem op = clstOppProds.remove(selectedRowNum);
return pg;
}

PageReference pg = null;
return pg;
}
public PageReference doSave(){
PageReference pg = null;
SavePoint sp = Database.setSavePoint();
try{
delete clstDelOppProds;
upsert clstOppProds;
pg = new PageReference('/'+cOpp.Id);
}catch(Exception e){
Database.rollback(sp);
}
return pg;
}
}```

Hi Experts,

I have small requirement where i need to filter a long text area field called Desc__c which i am not able to do that can anyone help me please.

OrderItem oli1 = new OrderItem ();
oli1.Orderid = order.Id;
oli1.Desc__c= 'Test OLI 1';
insert oli1;

OrderItem oli2 = [SELECT Id, Orderid
FROM OrderItem WHERE  Desc__c = 'Test OLI 1' LIMIT 1];

In this filter condition its throwing an error can anyone help me please thanks in adavance
Hi Experts,

Can anyone helps me , while running my test class i am getting below error. Below is my code anyone help  me please. the area which i made bold in the insert command i receiving this can anyone helps me please.

DUPLICATE_VALUE, This price definition already exists in this price book: []

Account a = new Account(Name='testAccount',RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId()); //Added by Purnima for Story S-562343
insert a;

Id pricebookId = Test.getStandardPricebookId();

Product2 prod = new Product2(Name = 'Laptop X200',
Family = 'Hardware');
insert prod;

/*PricebookEntry standardPrice = new PricebookEntry(
Pricebook2Id = pricebookId, Product2Id = prod.Id,
UnitPrice = 10000, IsActive = true);
insert standardPrice;*/

PriceBookEntry stdPriceBookEntry = new PriceBookEntry();
stdPriceBookEntry.Product2Id=prod.Id;
stdPriceBookEntry.Pricebook2Id=pricebookId;
stdPriceBookEntry.UnitPrice=2000;
stdPriceBookEntry.IsActive=true;
insert stdPriceBookEntry;

Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
insert customPB;

PricebookEntry customPrice = new PricebookEntry(
Pricebook2Id = customPB.Id, Product2Id = prod.Id,
UnitPrice = 12000, IsActive = true);
insert customPrice;
Product_Type__c productType = new Product_Type__c();
productType.Product_Type_Code__c = 'End';

insert productType;

Opportunity opp = new Opportunity(Name='Test',
Account = a,
// Product__c='GRI Retail',
NextStep='test',
PriceBook2 = customPB,
CloseDate = System.today(),
AccountId=a.Id,
// Opportunity_Name__c='testOpp',
// Product_Family__c='Retail',
Industry__c='Other',
Description='TestTestTest',
StageName='Closed Won - One Time'
);

insert opp;

List<Opportunity_Product__c> oppProdList = new List<Opportunity_Product__c>();
for(Integer i=1;i<=10;i++)
oppProdList.add(new Opportunity_Product__c (Opportunity__c = opp.Id,Product__c = productType.id));

System.debug('test@@@'+ oppProdList );

insert oppProdList;

ApexPages.StandardSetController sc = new ApexPages.StandardSetController(oppProdList);

PageReference pageRef = Page.OpportunityProducts;
pageRef.getParameters().put('id', String.valueOf(''));
Test.setCurrentPage(pageRef);

//Test.setCurrentPageReference(Page.OpportunityProducts);

OpportunityController obj= new OpportunityController(sc);
obj.selectedRowNum=1;
obj.selectedRowProdId=productType.id;
obj.selectedRowProdName=productType.Name;
obj.cOpp=opp;
List<Opportunity_Product__c> testopp= new List<Opportunity_Product__c>();
obj.clstOppProds=oppProdList;
List<Opportunity_Product__c> testOpps= new  List<Opportunity_Product__c>();
obj.clstDelOppProds=oppProdList;

obj.getJDEProductRTId();

//Product_Type__c pt = new Product_Type__c(id='test', name='test');
System.debug('clstOppProds==>' + obj.clstOppProds);
System.debug('clstDelOppProds==>' + obj.clstDelOppProds);

PageReference pg = obj.doSave();
//PageReference pg3 = obj.setProd();
PageReference pg2 = obj.removeRow();

Hi Experts,
I wrote one batch class with contractor like below. but when i was try to run my test class i am getting an error that constructor is not defind. below is my test class as well , can anyone help me plesae . thanks in advance
private  list<String> sOrganization;
public UpdateAccountCallList(String[] sorg) {
sOrganization = sorg;
}

Test class:

@isTest
public class AccountUpdatecallistBatchJobTest
{
static testMethod void testMethod1()
{
List<Account> lstAccount= new List<Account>();
List<Account> lstAccount1= new List<Account>();
List<Account> lstAccount2= new List<Account>();
List<Account> lstAccount3= new List<Account>();
List<Account> lstAccount4= new List<Account>();
List<Account> lstAccount5= new List<Account>();
for(Integer i=0 ;i <5;i++)
{
Account acc = new Account();
acc.Name =’Name’+i;
acc.Call_List_Frequency__c=8;
acc.Call_List__c=true;
acc.Call_List_Start_Date__c=system.today()-1;
acc.Call_List_Preferred_Day__c=’MOnday’;
date myDate = date.today();
acc.Call_List_Next_Preferred_Date__c=myDate.toStartofWeek()+0;
Account acc1 = new Account();
acc1.Name =’Name1’+i;
acc1.Call_List_Frequency__c=6.0;
acc1.Call_List__c=true;
acc1.Call_List_Start_Date__c=system.today()-1;
acc1.Call_List_Preferred_Day__c=’Tuesday’;
date myDate1 = date.today();
acc1.Call_List_Next_Preferred_Date__c=myDate1.toStartofWeek()+1;
Account acc2 = new Account();
acc2.Name =’Name1’+i;
acc2.Call_List_Frequency__c=6.0;
acc2.Call_List__c=true;
acc2.Call_List_Start_Date__c=system.today()+1;
acc2.Call_List_Preferred_Day__c=’Wednesday’;
date myDate2 = date.today();
acc2.Call_List_Next_Preferred_Date__c=myDate2.toStartofWeek()+2;
Account acc3 = new Account();
acc3.Name =’Name1’+i;
acc3.Call_List_Frequency__c=6.0;
acc3.Call_List__c=true;
acc3.Call_List_Start_Date__c=system.today()-1;
acc3.Call_List_Preferred_Day__c=’Thursday’;
date myDate3 = date.today();
acc3.Call_List_Next_Preferred_Date__c=myDate3.toStartofWeek()+3;
Account acc4 = new Account();
acc4.Name =’Name1’+i;
acc4.Call_List_Frequency__c=6.0;
acc4.Call_List__c=true;
acc4.Call_List_Start_Date__c=system.today()-1;
acc4.Call_List_Preferred_Day__c=’Friday’;
date myDate4 = date.today();
acc4.Call_List_Next_Preferred_Date__c=myDate4.toStartofWeek()+4;
Account acc5 = new Account();
acc5.Name =’Name1’+i;
acc5.Call_List_Frequency__c=6.0;
acc5.Call_List__c=true;
acc5.Call_List_Start_Date__c=system.today()-1;
acc5.Call_List_Preferred_Day__c=’None’;
acc5.Call_List_Next_Preferred_Date__c=system.today();
}
insert lstAccount;
insert lstAccount1;
insert lstAccount2;
insert lstAccount3;
insert lstAccount4;
insert lstAccount5;
Test.startTest();
UpdateAccountCallList obj = new UpdateAccountCallList();
obj.currentweek=9;
DataBase.executeBatch(obj);
Test.stopTest();
}
}
Hi Experts,

I have requirement i need to update the task owner once lead owner changes for me its working but getting too many soql errors when i chek debug log i am getting lot of records including my record , can anyone help me please, my trigger is after insert and after update which is on lead object.

{
system.debug('++++tsk'+tsk);
system.debug('++++owner'+owner);
system.debug('++++test'+test);
{
system.debug('++++owners'+tsk.ownerid);
}
}

Hi Experts,

I have below code which is calling before update on account ,i have nested loops because of that i am getting cpu time out issue, can anyone convert my code into MAp please.

Set<Id> Accids= New Set<Id>();
Set<String>Fun= new set<string>();

Id AccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('RecordType').getRecordTypeId();

if(AccRecordTypeId !=null)
{
FOR(Account A : newList)
{

if(A.RecordTypeId == AccRecordTypeId)
{
system.debug('%%%%%%'+Accids);
}

}

}
String samp = System.Label.User_ID;
List<Function__c> PR = [Select Id,Salesforce_ID__c,Function_Def__c,Person__c,Pernr__c from Function__c where Salesforce_ID__c IN : Accids and Pernr__c !=null ];
system.debug('\$\$\$\$\$\$'+PR );

for(Function__c pf: PR)
{
if( pf.Salesforce_ID__c != Null)
{
system.debug('^^^^^^'+pf);
system.debug('#######'+Fun);
}
}

list<Person__c> gp = [ select id , Employee_ID__c,User__c,OwnerId from Person__c where Employee_ID__c in : Fun];
system.debug('@@@@@'+gp );

if(gp.size()>0)
{

FOR(Account A : newList)

{

for(Person__c gpr: gp)
{
for( Function__c pfr: PR)
{
if(gpr.User__c!=null && pfr.Function_Def__c!=null )
{

if(pfr.Function_Def__c== 'ABC' )
{

system.debug('&&&&&'+gpr);
A.OwnerId=gpr.User__c;
system.debug('!!!!!'+A.ownerid);

}
else if(pfr.Function_Def__c== 'DEF' || pfr.Function_Def__c== 'GHI' || pfr.Function_Def__c== 'JKL')
{
A.OwnerId=gpr.User__c;
system.debug('88888'+A.ownerid);

}
}
else
{
A.OwnerId=samp;
system.debug('***'+A.ownerid);
}
}
}
}

}
I would like to update a check box to true when a button is pressed on a custom object, how do I do this using lightning component
Will add more records to update later, Any help is apreciated as i am ne to lightning