-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
25Questions
-
11Replies
while compiling the class i am getting folowing errors.
I am getting following errors in below code
Field is not writeable: AccountShare.AccountAccessLevel
Field is not writeable: AccountShare.CaseAccessLevel
Field is not writeable: AccountShare.OpportunityAccessLevel
Field is not writeable: AccountShare.AccountId
Field is not writeable: AccountShare.UserOrGroupId
if(z==0 && resgroup.get(asset.Reseller__c)!=null){
Accountshare ashare = new AccountShare();
ashare.AccountAccessLevel='Edit';
ashare.CaseAccessLevel='None';
ashare.OpportunityAccessLevel='None';
ashare.AccountId=asset.AccountId;
ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
newshares.add(ashare);
}
Field is not writeable: AccountShare.AccountAccessLevel
Field is not writeable: AccountShare.CaseAccessLevel
Field is not writeable: AccountShare.OpportunityAccessLevel
Field is not writeable: AccountShare.AccountId
Field is not writeable: AccountShare.UserOrGroupId
if(z==0 && resgroup.get(asset.Reseller__c)!=null){
Accountshare ashare = new AccountShare();
ashare.AccountAccessLevel='Edit';
ashare.CaseAccessLevel='None';
ashare.OpportunityAccessLevel='None';
ashare.AccountId=asset.AccountId;
ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
newshares.add(ashare);
}
-
- Jayaramu T 9
- March 21, 2019
- Like
- 0
- Continue reading or reply
String s ='SELECT Account.Name,Contact.Name,Subject,RecordType.Name,Issue_Summary__c FROM Case where Status = 'Closed'';
while saving i a getting following error
Error: Compile Error: Missing ';' at 'Closed' at line 439 column 120
in above query Status is picklist field values like 'Closed','New',Reopen'
Error: Compile Error: Missing ';' at 'Closed' at line 439 column 120
in above query Status is picklist field values like 'Closed','New',Reopen'
-
- Jayaramu T 9
- March 15, 2019
- Like
- 0
- Continue reading or reply
Hi All, following code returns a dynamic SOQL statement for the hole CASE object. but i want only some fields like Account Name,Contact Name,Subject,Issue Summary,Case Record Typeof case object. can any one please help me on this
// Returns a dynamic SOQL statement for the whole object, includes only creatable fields since we will be inserting a cloned result of this query
public static string getCreatableFieldsSOQL(String objectName){
String selects = '';
//if (whereClause == null || whereClause == ''){ return null; }
// Get a map of field name and field token
Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap();
list<string> selectFields = new list<string>();
if (fMap != null){
for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft)
Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd)
//if (fd.isCreateable()){ // field is creatable
selectFields.add(fd.getName());
//}
}
}
if (!selectFields.isEmpty()){
for (string s:selectFields){
selects += s + ',';
}
if (selects.endsWith(',')){selects = selects.substring(0,selects.lastIndexOf(','));}
}
return 'SELECT ' + selects + ' FROM ' + objectName;
}
public static string getCreatableFieldsSOQL(String objectName){
String selects = '';
//if (whereClause == null || whereClause == ''){ return null; }
// Get a map of field name and field token
Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap();
list<string> selectFields = new list<string>();
if (fMap != null){
for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft)
Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd)
//if (fd.isCreateable()){ // field is creatable
selectFields.add(fd.getName());
//}
}
}
if (!selectFields.isEmpty()){
for (string s:selectFields){
selects += s + ',';
}
if (selects.endsWith(',')){selects = selects.substring(0,selects.lastIndexOf(','));}
}
return 'SELECT ' + selects + ' FROM ' + objectName;
}
-
- Jayaramu T 9
- March 14, 2019
- Like
- 0
- Continue reading or reply
I want to use the custom labels in apex class for fetching the case object fields following below. can any one please help me on this?
Account Name
Contact Name
Subject
Issue Summary
Case Record Type
Contact Name
Subject
Issue Summary
Case Record Type
-
- Jayaramu T 9
- March 13, 2019
- Like
- 0
- Continue reading or reply
Can any one please let me know on this.
Critical Updates - Add a Namespace Prefix to Query Parameters and pageReference.state Properties
How to Activate and test this update in Org and pleae provide me if any one have examples on this.
How to Activate and test this update in Org and pleae provide me if any one have examples on this.
-
- Jayaramu T 9
- February 21, 2019
- Like
- 0
- Continue reading or reply
I have a field called ERP Instance Id. This field comes under Service Contracts.
I have a field called ERP Instance Id. This field comes under Service Contracts.
I have ERP Instance Id. I wanted to know the Service Contract ID based on that ERP Instance Id at SFDC.
I have ERP Instance Id. I wanted to know the Service Contract ID based on that ERP Instance Id at SFDC.
-
- Jayaramu T 9
- February 20, 2019
- Like
- 0
- Continue reading or reply
Can you please any one help on this? Please find the below is my code and PFA. based on if Active field unchecked in user object related contact object "Manage external user " disable the partner user
global class BatchDeactivateUsers implements Database.Batchable<sobject> {
global Database.QueryLocator start(Database.BatchableContext BC) {
Map<String,daystodeactivateuser__c> csdaystodeactivateuser = daystodeactivateuser__c.getAll();
integer noOfDays=0;
if(csdaystodeactivateuser!=null){
noOfDays = integer.ValueOf(csdaystodeactivateuser.get('numberofdaysemailnotificationsent').Numberofdays__c);
}
string query = 'SELECT Id,isActive,LastLoginDate,UserDeactivationDate__c FROM User where isActive=true and UserDeactivationDate__c!=null and UserDeactivationDate__c = TODAY and lastlogindate < LAST_N_DAYS:'+noOfDays;
if (!Test.IsRunningTest()) {
return Database.getQueryLocator(query);
} else {
return Database.getQueryLocator('SELECT Id,isActive,LastLoginDate,UserDeactivationDate__c FROM User limit 1');
}
}
global void execute(Database.BatchableContext BC, List<user> userList) {
for (User usrRec: userList) {
usrRec.isActive = false;
if(usrRec.contactId!=null){
usrRec.isPortalenabled = false;
}
}
if (userList.size() > 0 && !Test.isRunningTest()) {
update userList;
}
}
global void finish(Database.BatchableContext BC) {}
}
-
- Jayaramu T 9
- January 21, 2019
- Like
- 0
- Continue reading or reply
in below code at line number 8. i am getting "Too many SOQL 101" error while running my test class. can any one please suggest me on this?
public static void onAfterUpdate(Case[] oldRecords, Case[] updatedRecords, Map<ID, Case> oldRecordMap)
{
autoAssignCase(updatedRecords);
// Take new cases, bulkified
LIST<Case> caselist = Trigger.new;
// Find all Custom Settings defining default Case Milestones
LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
// Loop through each Custom Setting for Case Milestones
//Fixed LOOp Standard case settings
Set<Id> mstoneID = new Set<Id>();
String alias;
List<CaseMilestone> setmstones ;
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
for (CaseMilestoneSetting__c CMileS : CMileSs){
mstoneID.add(CMileS.MilestoneID__c);
if(CMileS.CaseCriteria__c != null){
alias = CMileS.CaseCriteria__c;
}
}
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+ alias+ 'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
if(lp_setmstones.size()>0)
{
// Execute the update for all the Milestones in this set
update lp_setmstones;
}
Map<ID,Case> installCases = new Map<ID,Case>();
ID InstallID;
List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
if(installTypes.size()>0){
InstallID=installTypes[0].Id;
}
for(Case c : updatedRecords){
if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
installCases.put(c.AssetId,c);
}
}
Asset_Util.UpdateAssetInstall(installCases);
//Porcess Builder - Case - update asset fields
updateAssetFields(updatedRecords);
}
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
@testSetup static void setup(){
Integer pastYear = Date.today().addYears(-2).year();
Date pastDate = Date.newInstance(pastYear, 01, 01);
Date currentDate =Date.today();
String blankVal ='';
Product2 pro= new Product2();
pro.Product_Group__c='Consumer Products';
pro.Product_Collection__c='3D Printers';
pro.Product_Category__c='CubeX';
pro.Name='Common34';
insert pro;
Asset[] assetRecList= new List<Asset>();
Integer currYear = Date.today().year();
for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
Asset ast;
for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
ast=new Asset();
ast.Name='Assettest';
ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
ast.InstallDate=date.newInstance(z, assetMonth, 1);
ast.Product2Id = pro.Id;
System.debug('@@ShipYear'+ast.Ship_Date__c);
System.debug('@@assetMonth'+ast.InstallDate);
assetRecList.add(ast);
}
}
insert assetRecList;
Asset as1= new Asset();
as1.Name='Assettest';
as1.Ship_Date__c = date.newInstance(2016, 1, 1);
as1.InstallDate=date.newInstance(2016, 1, 1);
as1.Product2Id = pro.Id;
insert as1;
List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
System.debug('@@lsAsset'+lsAsset);
Integer assetCount= [select count() from Asset where id IN: assetRecList];
//System.assertEquals(3, assetCount);
Asset j=assetRecList[0];
id u=j.id;
Issue__c iss=new Issue__c();
iss.Name='Issuename1';
iss.Active__c=True;
iss.Product_Group__c='Consumer Products';
iss.Product_Collection__c='3D Printers';
insert iss;
List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
Id k;
RecordType p=i[0];
k=p.id;
//Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;
Case[] CaseList= new List<Case>();
Integer assetIndex =0;
for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
Case cs;
for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
cs =new Case();
cs.RecordTypeId = InstReport ; //change from InstReport to k
cs.bypassvalidation__c = true;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[assetIndex].Id;
if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
CaseList.add(cs);
system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
assetIndex++;
}
}
system.debug('***CaseList***'+CaseList);
insert CaseList;
Case[] CaseList2= new List<Case>();
for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
Case cs =new Case();
cs.RecordTypeId= k ;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[MonthCounter-1].Id;
CaseList2.add(cs);
}
system.debug('***CaseList2***'+CaseList2);
insert CaseList2;
Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
Integer casecount=0;
for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
Case_Issue__c csiss;
for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
csiss =new Case_Issue__c();
csiss.Case__c = CaseList[casecount].id;
csiss.Issue__c= iss.id;
csiss.Product_Group__c='Consumer Products';
csiss.Product_Collection__c='3D Printers';
//Integer installedYear = csiss.asset.InstallDate.year();
casecount++;
CaseIssueList.add(csiss);
}
}
}
system.debug('***CaseIssueList***'+CaseIssueList);
insert CaseIssueList;
RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
custSettings.Name = 'RPUBatchRunTime';
custSettings.Dashboard_Run_Date__c = system.now();
custSettings.Status__c = 'Incomplete';
insert custSettings;
}
public static testmethod void rputest(){
test.starttest();
setup();
RPUDashboardBatch rs=new RPUDashboardBatch();
rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
Database.executebatch(rs,200);
test.stoptest();
}
static testMethod void createData(){
test.starttest();
Account act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
insert act;
Product2 product2_1 = new Product2(
Name = 'NFR - Freeform Plus',
CanUseRevenueSchedule = false,
IsActive = true,
CurrencyIsoCode = 'USD',
fw2__Non_Installment__c = false,
fw2__Recurring__c = false,
Published__c = true,
IsFlex__c = true,
Asset_Tracking__c = false,
ERP_Taxable_Flag__c = false,
Servicing_Only__c = false,
IsEDU__c = false,
ERP_COMS_NL_TRACKABLE__c = false,
Asset_Tracking_Override__c = false,
CPQNewSale__c = false,
Product_Collection__c ='Geomagic'
);
insert product2_1;
Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
insert ass;
Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
insert resell2;
Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
insert opp;
test.stoptest();
}
}
{
autoAssignCase(updatedRecords);
// Take new cases, bulkified
LIST<Case> caselist = Trigger.new;
// Find all Custom Settings defining default Case Milestones
LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
// Loop through each Custom Setting for Case Milestones
//Fixed LOOp Standard case settings
Set<Id> mstoneID = new Set<Id>();
String alias;
List<CaseMilestone> setmstones ;
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
for (CaseMilestoneSetting__c CMileS : CMileSs){
mstoneID.add(CMileS.MilestoneID__c);
if(CMileS.CaseCriteria__c != null){
alias = CMileS.CaseCriteria__c;
}
}
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+ alias+ 'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
if(lp_setmstones.size()>0)
{
// Execute the update for all the Milestones in this set
update lp_setmstones;
}
Map<ID,Case> installCases = new Map<ID,Case>();
ID InstallID;
List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
if(installTypes.size()>0){
InstallID=installTypes[0].Id;
}
for(Case c : updatedRecords){
if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
installCases.put(c.AssetId,c);
}
}
Asset_Util.UpdateAssetInstall(installCases);
//Porcess Builder - Case - update asset fields
updateAssetFields(updatedRecords);
}
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
@testSetup static void setup(){
Integer pastYear = Date.today().addYears(-2).year();
Date pastDate = Date.newInstance(pastYear, 01, 01);
Date currentDate =Date.today();
String blankVal ='';
Product2 pro= new Product2();
pro.Product_Group__c='Consumer Products';
pro.Product_Collection__c='3D Printers';
pro.Product_Category__c='CubeX';
pro.Name='Common34';
insert pro;
Asset[] assetRecList= new List<Asset>();
Integer currYear = Date.today().year();
for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
Asset ast;
for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
ast=new Asset();
ast.Name='Assettest';
ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
ast.InstallDate=date.newInstance(z, assetMonth, 1);
ast.Product2Id = pro.Id;
System.debug('@@ShipYear'+ast.Ship_Date__c);
System.debug('@@assetMonth'+ast.InstallDate);
assetRecList.add(ast);
}
}
insert assetRecList;
Asset as1= new Asset();
as1.Name='Assettest';
as1.Ship_Date__c = date.newInstance(2016, 1, 1);
as1.InstallDate=date.newInstance(2016, 1, 1);
as1.Product2Id = pro.Id;
insert as1;
List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
System.debug('@@lsAsset'+lsAsset);
Integer assetCount= [select count() from Asset where id IN: assetRecList];
//System.assertEquals(3, assetCount);
Asset j=assetRecList[0];
id u=j.id;
Issue__c iss=new Issue__c();
iss.Name='Issuename1';
iss.Active__c=True;
iss.Product_Group__c='Consumer Products';
iss.Product_Collection__c='3D Printers';
insert iss;
List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
Id k;
RecordType p=i[0];
k=p.id;
//Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;
Case[] CaseList= new List<Case>();
Integer assetIndex =0;
for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
Case cs;
for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
cs =new Case();
cs.RecordTypeId = InstReport ; //change from InstReport to k
cs.bypassvalidation__c = true;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[assetIndex].Id;
if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
CaseList.add(cs);
system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
assetIndex++;
}
}
system.debug('***CaseList***'+CaseList);
insert CaseList;
Case[] CaseList2= new List<Case>();
for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
Case cs =new Case();
cs.RecordTypeId= k ;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[MonthCounter-1].Id;
CaseList2.add(cs);
}
system.debug('***CaseList2***'+CaseList2);
insert CaseList2;
Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
Integer casecount=0;
for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
Case_Issue__c csiss;
for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
csiss =new Case_Issue__c();
csiss.Case__c = CaseList[casecount].id;
csiss.Issue__c= iss.id;
csiss.Product_Group__c='Consumer Products';
csiss.Product_Collection__c='3D Printers';
//Integer installedYear = csiss.asset.InstallDate.year();
casecount++;
CaseIssueList.add(csiss);
}
}
}
system.debug('***CaseIssueList***'+CaseIssueList);
insert CaseIssueList;
RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
custSettings.Name = 'RPUBatchRunTime';
custSettings.Dashboard_Run_Date__c = system.now();
custSettings.Status__c = 'Incomplete';
insert custSettings;
}
public static testmethod void rputest(){
test.starttest();
setup();
RPUDashboardBatch rs=new RPUDashboardBatch();
rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
Database.executebatch(rs,200);
test.stoptest();
}
static testMethod void createData(){
test.starttest();
Account act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
insert act;
Product2 product2_1 = new Product2(
Name = 'NFR - Freeform Plus',
CanUseRevenueSchedule = false,
IsActive = true,
CurrencyIsoCode = 'USD',
fw2__Non_Installment__c = false,
fw2__Recurring__c = false,
Published__c = true,
IsFlex__c = true,
Asset_Tracking__c = false,
ERP_Taxable_Flag__c = false,
Servicing_Only__c = false,
IsEDU__c = false,
ERP_COMS_NL_TRACKABLE__c = false,
Asset_Tracking_Override__c = false,
CPQNewSale__c = false,
Product_Collection__c ='Geomagic'
);
insert product2_1;
Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
insert ass;
Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
insert resell2;
Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
insert opp;
test.stoptest();
}
}
-
- Jayaramu T 9
- November 20, 2018
- Like
- 0
- Continue reading or reply
can any one please help on this i am keep on getting Flow Error mails from my sandbox
FlowApplication <info@salesforce.com>
Error element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Product2.Product_Category__c because it hasn't been set or assigned.
Flow Details
Flow Name: Asset_Product_Category
Type: Record Change Process
Version: 1
Status: Active
Org: 3D Systems, Inc. (00D3D000000DPRO)
Flow Interview Details
Interview Label: Asset_Product_Category-5_InterviewLabel
Current User: Salesforce CPQ (00534000009QVTC)
Start time: 11/16/2018 3:13 AM
Duration: 0 seconds
How the Interview Started
Salesforce CPQ (00534000009QVTC) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = Asset (02i34000006VTtTAAW)
myVariable_current = Asset (02i34000006VTtTAAW)
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!$Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "11/16/2018 3:13 AM"
DECISION: isChangedDecision2_myRule_1_Product2Id
Skipped this outcome because its conditions weren't met: isChangedRule_2_myRule_1_Product2Id
Outcome conditions:
1. {!myVariable_old} (Asset (02i34000006VTtTAAW)) Is null false
2. {!myVariable_old.Product2Id} (null) Does not equal {!myVariable_current.Product2Id} (null)
Logic: All conditions must be true (AND)
Executed the default outcome
Salesforce Error ID: 2018615494-11105 (-2052676383)
Error element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Product2.Product_Category__c because it hasn't been set or assigned.
Flow Details
Flow Name: Asset_Product_Category
Type: Record Change Process
Version: 1
Status: Active
Org: 3D Systems, Inc. (00D3D000000DPRO)
Flow Interview Details
Interview Label: Asset_Product_Category-5_InterviewLabel
Current User: Salesforce CPQ (00534000009QVTC)
Start time: 11/16/2018 3:13 AM
Duration: 0 seconds
How the Interview Started
Salesforce CPQ (00534000009QVTC) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = Asset (02i34000006VTtTAAW)
myVariable_current = Asset (02i34000006VTtTAAW)
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!$Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "11/16/2018 3:13 AM"
DECISION: isChangedDecision2_myRule_1_Product2Id
Skipped this outcome because its conditions weren't met: isChangedRule_2_myRule_1_Product2Id
Outcome conditions:
1. {!myVariable_old} (Asset (02i34000006VTtTAAW)) Is null false
2. {!myVariable_old.Product2Id} (null) Does not equal {!myVariable_current.Product2Id} (null)
Logic: All conditions must be true (AND)
Executed the default outcome
Salesforce Error ID: 2018615494-11105 (-2052676383)
-
- Jayaramu T 9
- November 16, 2018
- Like
- 0
- Continue reading or reply
please help on this i am getting Limit Exception : Too many SOQL queries: 101 on below code
private static testmethod void oobbatchtest(){
test.starttest();
setup();
OOBDashboardBatch rs=new OOBDashboardBatch();
Database.executebatch(rs,200);
test.stoptest();
test.starttest();
setup();
OOBDashboardBatch rs=new OOBDashboardBatch();
Database.executebatch(rs,200);
test.stoptest();
-
- Jayaramu T 9
- November 14, 2018
- Like
- 0
- Continue reading or reply
can any one please help me on this?
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger:
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger.
could you please follow the below code.
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger.
could you please follow the below code.
-
- Jayaramu T 9
- November 06, 2018
- Like
- 0
- Continue reading or reply
can any one please help me on this, Detail a solution for the following ?
On the Opportunity object, prevent non-admin users from modify the Opportunity Name once Probability is greater than 50% and prevent Opportunity from being deleted if Probability greater than or equal to 75% (Please show code as necessary)
-
- Jayaramu T 9
- October 09, 2018
- Like
- 0
- Continue reading or reply
any one have any idea on how to avoid "unescaped attribute value XSS" in the following code?
onclick="javascript:if ('{!selectedAccount}' != 'NEW' && '{!selectedAccount}' != 'NONE' ) {var newWindow = window.open('/{!selectedAccount}/p', 'accountview', 'top=40, left=40,scrollbars=yes, height=450, width=800');newwindow.focus();}
-
- Jayaramu T 9
- September 12, 2018
- Like
- 0
- Continue reading or reply
I want to avoid "database.query(cvQuery)" this in for loop because it is getting toomany SOQL statements can any one please help me on this?
for(List<ContentVersion> cvObjList : database.query(cvQuery))
-
- Jayaramu T 9
- September 10, 2018
- Like
- 0
- Continue reading or reply
can any one please help me on this.
could you please let me know how can i use line breks in "visualforce email templates" ?
-
- Jayaramu T 9
- September 06, 2018
- Like
- 0
- Continue reading or reply
Can any one please help me on this ?
Error: Unknown property 'core.email.template.EmailTemplateComponentController.Account'
<messaging:emailTemplate subject="New email and New Case" recipientType="User" relatedToType="Case">
<messaging:plainTextEmailBody >
*** CASE EMAIL ALERT For NEW CASE***
The following case has a new inbound email associated with it and it has been reopened:
Case: {!relatedTo.CaseNumber}: {!relatedTo.Subject}
Web name: {!relatedTo.SuppliedName}
Web company: {!relatedTo.SuppliedCompany}
Web e-mail: {!relatedTo.SuppliedEmail}
Web phone number: {!relatedTo.SuppliedPhone}
Company: {!Account.Name}
Contact Name: {!Contact.Name}
Contact e-mail: {!Contact.Email}
Contact phone number: {!Contact.Phone}
Case #: {!Case.CaseNumber}
Subject: {!Case.Subject}
Description:
{!Case.Description}
Click on the link to access the case: {!Case.Link}</messaging:plainTextEmailBody>
</messaging:emailTemplate>
<messaging:emailTemplate subject="New email and New Case" recipientType="User" relatedToType="Case">
<messaging:plainTextEmailBody >
*** CASE EMAIL ALERT For NEW CASE***
The following case has a new inbound email associated with it and it has been reopened:
Case: {!relatedTo.CaseNumber}: {!relatedTo.Subject}
Web name: {!relatedTo.SuppliedName}
Web company: {!relatedTo.SuppliedCompany}
Web e-mail: {!relatedTo.SuppliedEmail}
Web phone number: {!relatedTo.SuppliedPhone}
Company: {!Account.Name}
Contact Name: {!Contact.Name}
Contact e-mail: {!Contact.Email}
Contact phone number: {!Contact.Phone}
Case #: {!Case.CaseNumber}
Subject: {!Case.Subject}
Description:
{!Case.Description}
Click on the link to access the case: {!Case.Link}</messaging:plainTextEmailBody>
</messaging:emailTemplate>
-
- Jayaramu T 9
- August 29, 2018
- Like
- 0
- Continue reading or reply
If any one have any idea on this please help me?
I want to create custom setting for "new case creation after 7 days" in future it may increase to 30 days also and How to refer this custom setting in " Process Builder"?
-
- Jayaramu T 9
- August 27, 2018
- Like
- 0
- Continue reading or reply
in below code at line number 8. i am getting "Too many SOQL 101" error while running my test class. can any one please suggest me on this?
public static void onAfterUpdate(Case[] oldRecords, Case[] updatedRecords, Map<ID, Case> oldRecordMap)
{
autoAssignCase(updatedRecords);
// Take new cases, bulkified
LIST<Case> caselist = Trigger.new;
// Find all Custom Settings defining default Case Milestones
LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
// Loop through each Custom Setting for Case Milestones
//Fixed LOOp Standard case settings
Set<Id> mstoneID = new Set<Id>();
String alias;
List<CaseMilestone> setmstones ;
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
for (CaseMilestoneSetting__c CMileS : CMileSs){
mstoneID.add(CMileS.MilestoneID__c);
if(CMileS.CaseCriteria__c != null){
alias = CMileS.CaseCriteria__c;
}
}
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+ alias+ 'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
if(lp_setmstones.size()>0)
{
// Execute the update for all the Milestones in this set
update lp_setmstones;
}
Map<ID,Case> installCases = new Map<ID,Case>();
ID InstallID;
List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
if(installTypes.size()>0){
InstallID=installTypes[0].Id;
}
for(Case c : updatedRecords){
if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
installCases.put(c.AssetId,c);
}
}
Asset_Util.UpdateAssetInstall(installCases);
//Porcess Builder - Case - update asset fields
updateAssetFields(updatedRecords);
}
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
@testSetup static void setup(){
Integer pastYear = Date.today().addYears(-2).year();
Date pastDate = Date.newInstance(pastYear, 01, 01);
Date currentDate =Date.today();
String blankVal ='';
Product2 pro= new Product2();
pro.Product_Group__c='Consumer Products';
pro.Product_Collection__c='3D Printers';
pro.Product_Category__c='CubeX';
pro.Name='Common34';
insert pro;
Asset[] assetRecList= new List<Asset>();
Integer currYear = Date.today().year();
for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
Asset ast;
for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
ast=new Asset();
ast.Name='Assettest';
ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
ast.InstallDate=date.newInstance(z, assetMonth, 1);
ast.Product2Id = pro.Id;
System.debug('@@ShipYear'+ast.Ship_Date__c);
System.debug('@@assetMonth'+ast.InstallDate);
assetRecList.add(ast);
}
}
insert assetRecList;
Asset as1= new Asset();
as1.Name='Assettest';
as1.Ship_Date__c = date.newInstance(2016, 1, 1);
as1.InstallDate=date.newInstance(2016, 1, 1);
as1.Product2Id = pro.Id;
insert as1;
List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
System.debug('@@lsAsset'+lsAsset);
Integer assetCount= [select count() from Asset where id IN: assetRecList];
//System.assertEquals(3, assetCount);
Asset j=assetRecList[0];
id u=j.id;
Issue__c iss=new Issue__c();
iss.Name='Issuename1';
iss.Active__c=True;
iss.Product_Group__c='Consumer Products';
iss.Product_Collection__c='3D Printers';
insert iss;
List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
Id k;
RecordType p=i[0];
k=p.id;
//Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;
Case[] CaseList= new List<Case>();
Integer assetIndex =0;
for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
Case cs;
for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
cs =new Case();
cs.RecordTypeId = InstReport ; //change from InstReport to k
cs.bypassvalidation__c = true;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[assetIndex].Id;
if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
CaseList.add(cs);
system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
assetIndex++;
}
}
system.debug('***CaseList***'+CaseList);
insert CaseList;
Case[] CaseList2= new List<Case>();
for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
Case cs =new Case();
cs.RecordTypeId= k ;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[MonthCounter-1].Id;
CaseList2.add(cs);
}
system.debug('***CaseList2***'+CaseList2);
insert CaseList2;
Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
Integer casecount=0;
for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
Case_Issue__c csiss;
for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
csiss =new Case_Issue__c();
csiss.Case__c = CaseList[casecount].id;
csiss.Issue__c= iss.id;
csiss.Product_Group__c='Consumer Products';
csiss.Product_Collection__c='3D Printers';
//Integer installedYear = csiss.asset.InstallDate.year();
casecount++;
CaseIssueList.add(csiss);
}
}
}
system.debug('***CaseIssueList***'+CaseIssueList);
insert CaseIssueList;
RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
custSettings.Name = 'RPUBatchRunTime';
custSettings.Dashboard_Run_Date__c = system.now();
custSettings.Status__c = 'Incomplete';
insert custSettings;
}
public static testmethod void rputest(){
test.starttest();
setup();
RPUDashboardBatch rs=new RPUDashboardBatch();
rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
Database.executebatch(rs,200);
test.stoptest();
}
static testMethod void createData(){
test.starttest();
Account act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
insert act;
Product2 product2_1 = new Product2(
Name = 'NFR - Freeform Plus',
CanUseRevenueSchedule = false,
IsActive = true,
CurrencyIsoCode = 'USD',
fw2__Non_Installment__c = false,
fw2__Recurring__c = false,
Published__c = true,
IsFlex__c = true,
Asset_Tracking__c = false,
ERP_Taxable_Flag__c = false,
Servicing_Only__c = false,
IsEDU__c = false,
ERP_COMS_NL_TRACKABLE__c = false,
Asset_Tracking_Override__c = false,
CPQNewSale__c = false,
Product_Collection__c ='Geomagic'
);
insert product2_1;
Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
insert ass;
Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
insert resell2;
Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
insert opp;
test.stoptest();
}
}
{
autoAssignCase(updatedRecords);
// Take new cases, bulkified
LIST<Case> caselist = Trigger.new;
// Find all Custom Settings defining default Case Milestones
LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
// Loop through each Custom Setting for Case Milestones
//Fixed LOOp Standard case settings
Set<Id> mstoneID = new Set<Id>();
String alias;
List<CaseMilestone> setmstones ;
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
for (CaseMilestoneSetting__c CMileS : CMileSs){
mstoneID.add(CMileS.MilestoneID__c);
if(CMileS.CaseCriteria__c != null){
alias = CMileS.CaseCriteria__c;
}
}
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+ alias+ 'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
if(lp_setmstones.size()>0)
{
// Execute the update for all the Milestones in this set
update lp_setmstones;
}
Map<ID,Case> installCases = new Map<ID,Case>();
ID InstallID;
List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
if(installTypes.size()>0){
InstallID=installTypes[0].Id;
}
for(Case c : updatedRecords){
if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
installCases.put(c.AssetId,c);
}
}
Asset_Util.UpdateAssetInstall(installCases);
//Porcess Builder - Case - update asset fields
updateAssetFields(updatedRecords);
}
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
@testSetup static void setup(){
Integer pastYear = Date.today().addYears(-2).year();
Date pastDate = Date.newInstance(pastYear, 01, 01);
Date currentDate =Date.today();
String blankVal ='';
Product2 pro= new Product2();
pro.Product_Group__c='Consumer Products';
pro.Product_Collection__c='3D Printers';
pro.Product_Category__c='CubeX';
pro.Name='Common34';
insert pro;
Asset[] assetRecList= new List<Asset>();
Integer currYear = Date.today().year();
for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
Asset ast;
for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
ast=new Asset();
ast.Name='Assettest';
ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
ast.InstallDate=date.newInstance(z, assetMonth, 1);
ast.Product2Id = pro.Id;
System.debug('@@ShipYear'+ast.Ship_Date__c);
System.debug('@@assetMonth'+ast.InstallDate);
assetRecList.add(ast);
}
}
insert assetRecList;
Asset as1= new Asset();
as1.Name='Assettest';
as1.Ship_Date__c = date.newInstance(2016, 1, 1);
as1.InstallDate=date.newInstance(2016, 1, 1);
as1.Product2Id = pro.Id;
insert as1;
List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
System.debug('@@lsAsset'+lsAsset);
Integer assetCount= [select count() from Asset where id IN: assetRecList];
//System.assertEquals(3, assetCount);
Asset j=assetRecList[0];
id u=j.id;
Issue__c iss=new Issue__c();
iss.Name='Issuename1';
iss.Active__c=True;
iss.Product_Group__c='Consumer Products';
iss.Product_Collection__c='3D Printers';
insert iss;
List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
Id k;
RecordType p=i[0];
k=p.id;
//Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;
Case[] CaseList= new List<Case>();
Integer assetIndex =0;
for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
Case cs;
for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
cs =new Case();
cs.RecordTypeId = InstReport ; //change from InstReport to k
cs.bypassvalidation__c = true;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[assetIndex].Id;
if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
CaseList.add(cs);
system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
assetIndex++;
}
}
system.debug('***CaseList***'+CaseList);
insert CaseList;
Case[] CaseList2= new List<Case>();
for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
Case cs =new Case();
cs.RecordTypeId= k ;
cs.Status='Open';
cs.Description='testdescription';
cs.AssetID=assetRecList[MonthCounter-1].Id;
CaseList2.add(cs);
}
system.debug('***CaseList2***'+CaseList2);
insert CaseList2;
Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
Integer casecount=0;
for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
Case_Issue__c csiss;
for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
csiss =new Case_Issue__c();
csiss.Case__c = CaseList[casecount].id;
csiss.Issue__c= iss.id;
csiss.Product_Group__c='Consumer Products';
csiss.Product_Collection__c='3D Printers';
//Integer installedYear = csiss.asset.InstallDate.year();
casecount++;
CaseIssueList.add(csiss);
}
}
}
system.debug('***CaseIssueList***'+CaseIssueList);
insert CaseIssueList;
RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
custSettings.Name = 'RPUBatchRunTime';
custSettings.Dashboard_Run_Date__c = system.now();
custSettings.Status__c = 'Incomplete';
insert custSettings;
}
public static testmethod void rputest(){
test.starttest();
setup();
RPUDashboardBatch rs=new RPUDashboardBatch();
rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
Database.executebatch(rs,200);
test.stoptest();
}
static testMethod void createData(){
test.starttest();
Account act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
insert act;
Product2 product2_1 = new Product2(
Name = 'NFR - Freeform Plus',
CanUseRevenueSchedule = false,
IsActive = true,
CurrencyIsoCode = 'USD',
fw2__Non_Installment__c = false,
fw2__Recurring__c = false,
Published__c = true,
IsFlex__c = true,
Asset_Tracking__c = false,
ERP_Taxable_Flag__c = false,
Servicing_Only__c = false,
IsEDU__c = false,
ERP_COMS_NL_TRACKABLE__c = false,
Asset_Tracking_Override__c = false,
CPQNewSale__c = false,
Product_Collection__c ='Geomagic'
);
insert product2_1;
Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
insert ass;
Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
insert resell2;
Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
insert opp;
test.stoptest();
}
}
- Jayaramu T 9
- November 20, 2018
- Like
- 0
- Continue reading or reply
can any one please help me on this?
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger:
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger.
could you please follow the below code.
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger.
could you please follow the below code.
- Jayaramu T 9
- November 06, 2018
- Like
- 0
- Continue reading or reply
can any one please help me on this.
could you please let me know how can i use line breks in "visualforce email templates" ?
- Jayaramu T 9
- September 06, 2018
- Like
- 0
- Continue reading or reply
If any one have any idea on this please help me?
I want to create custom setting for "new case creation after 7 days" in future it may increase to 30 days also and How to refer this custom setting in " Process Builder"?
- Jayaramu T 9
- August 27, 2018
- Like
- 0
- Continue reading or reply
Apex Trigger logic for the following requirement
If a case is closed, and the customer replies to an email, it would automatically re-open case. If past the 7 day mark, if a replies comes it a new case should be created and routed to appropriate queue
- Jayaramu T 9
- August 08, 2018
- Like
- 0
- Continue reading or reply
I need to avoid SOQL query inside for loop but it is using for loop reference variable any suggetions please to avoid soql in loop . and what is the use of "system.test.isRunningTest()" in below code
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
for (CaseMilestoneSetting__c CMileS : CMileSs){
id mstoneID = CMileS.MilestoneID__c;
// Find all CaseMilestones matching our criteria in our caselist
LIST<CaseMilestone> setmstones;
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+
CMileS.CaseCriteria__c+
'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
}
for (CaseMilestoneSetting__c CMileS : CMileSs){
id mstoneID = CMileS.MilestoneID__c;
// Find all CaseMilestones matching our criteria in our caselist
LIST<CaseMilestone> setmstones;
if(system.test.isRunningTest())
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+
CMileS.CaseCriteria__c+
'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
// Update the CompletionDate for each CaseMilesone
for (CaseMilestone updatemstone : setmstones){
updatemstone.CompletionDate= Datetime.now();
}
// Execute the update for all the Milestones in this set
lp_setmstones.addAll(setmstones);
}
- Jayaramu T 9
- August 02, 2018
- Like
- 0
- Continue reading or reply
I need to avoid SOQL query inside for loop but it is using for loop reference variable any suggetions please to avoid soql in loop below is the code
public Pricebook2 theBook {get;set;}
public List<Authorized_Product__c> authorizedProductObjList =[SELECT Active__c,Distribution_Type__c,Id,Name,Product_Category__c,Product_Collection__c,Price_Book__c,
Product_Family__c,Reseller__c,Standard_Discount__c,Demo_Unit_Discount__c ,Parts_Discount__c,Material_Discount__c
FROM Authorized_Product__c WHERE Reseller__c = :theOpp.RapidForm_Reseller__c AND Active__c = true];
for(Authorized_Product__c authp : authorizedProductObjList){
if(PPP && authp.Product_Family__c.contains('Printers') && authp.Price_Book__c!=null){
theBook = [select Id, Name from Pricebook2 where ID = :authp.Price_book__c];
forcePricebookSelection=false;
}
}
}
- Jayaramu T 9
- August 01, 2018
- Like
- 0
- Continue reading or reply