-
ChatterFeed
-
10Best Answers
-
0Likes Received
-
0Likes Given
-
1Questions
-
38Replies
Help with this code please!!
I am trying to get the current case record Id. I will be using this class in a trigger. Thank you!!!
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (Apex Pages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.currentPage().
getParameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Here are the errors I am receiving:
1) Unexpected token '.'.
2)Invalid character in identifier: Pages.StandardController
3)Invalid type: Apex
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (Apex Pages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.currentPage().
getParameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Here are the errors I am receiving:
1) Unexpected token '.'.
2)Invalid character in identifier: Pages.StandardController
3)Invalid type: Apex
- Abby Stocker
- November 13, 2019
- Like
- 0
- Continue reading or reply
Test class for Contoller's method which involve attachment insert
Hello, can anyone help me in this question, in this method i am some custom record as well as attachment, my test class is running for custom records but it gives error "System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]"
this is method's code ,
Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ;
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;
lprop.Current_Record_ID__c = lpdocument.ID;
upsert lprop;
PageReference p = new PageReference('/' + this.lprop.Id );
return p;
}
and this is my test class for this controller
@isTest
public class addProposalCntrltest2{
static testMethod void testMethod1() {
Lead testRecord= new Lead();
testRecord.LastName = 'test name ';
testRecord.Company = 'test company';
testRecord.Status = 'new';
testRecord.Credit_Limit_Amount__c = 12344;
insert testRecord;
Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
testRecord2.Name = 'test';
testRecord2.Lead__c= testRecord.ID;
insert testRecord2 ;
Blob lpfileBody = Blob.valueOf('Test Data');
Attachment attachment = new Attachment();
attachment.Name = 'Test Attachment for Parent';
attachment.ParentId = testRecord2.ID;
attachment.Body = lpfileBody;
insert attachment;
Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
testRecord3.Name = 'test';
testRecord3.Lead__c= testRecord.ID;
insert testRecord3;
Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
testRecord4.Name = 'test';
testRecord4.Lead__c= testRecord.ID;
insert testRecord4 ;
Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
testRecord5.Name = 'test';
testRecord5.Lead__c= testRecord.ID;
Insert testRecord5;
Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
testRecord6.Name = 'test';
testRecord6.Lead__c= testRecord.ID;
insert testRecord6 ;
Floor_Cleaning_Project_Over_View__c testRecord7 = new Floor_Cleaning_Project_Over_View__c();
testRecord7.Name = 'test';
testRecord7.Lead__c= testRecord.ID;
insert testRecord7;
General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
testRecord8.Name = 'test';
testRecord8.Lead__c= testRecord.ID;
insert testRecord8;
Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
testRecord9.Name = 'test';
testRecord9.Lead__c= testRecord.ID;
insert testRecord9 ;
Test.setCurrentPage(Page.addProposal);
System.currentPageReference().getParameters().put('id', testRecord.Id);
addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
addProposalCntrlTestIns.saveRecordlprop();
addProposalCntrlTestIns.saveRecordspropComm();
addProposalCntrlTestIns.saveRecordspropResd();
addProposalCntrlTestIns.saveRecordpprop1();
addProposalCntrlTestIns.saveRecordpprop2();
addProposalCntrlTestIns.saveRecordpprop3();
}
private static void addAttachmentToParent(Id testRecord) {
}
}
Thank you!
this is method's code ,
Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ;
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;
lprop.Current_Record_ID__c = lpdocument.ID;
upsert lprop;
PageReference p = new PageReference('/' + this.lprop.Id );
return p;
}
and this is my test class for this controller
@isTest
public class addProposalCntrltest2{
static testMethod void testMethod1() {
Lead testRecord= new Lead();
testRecord.LastName = 'test name ';
testRecord.Company = 'test company';
testRecord.Status = 'new';
testRecord.Credit_Limit_Amount__c = 12344;
insert testRecord;
Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
testRecord2.Name = 'test';
testRecord2.Lead__c= testRecord.ID;
insert testRecord2 ;
Blob lpfileBody = Blob.valueOf('Test Data');
Attachment attachment = new Attachment();
attachment.Name = 'Test Attachment for Parent';
attachment.ParentId = testRecord2.ID;
attachment.Body = lpfileBody;
insert attachment;
Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
testRecord3.Name = 'test';
testRecord3.Lead__c= testRecord.ID;
insert testRecord3;
Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
testRecord4.Name = 'test';
testRecord4.Lead__c= testRecord.ID;
insert testRecord4 ;
Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
testRecord5.Name = 'test';
testRecord5.Lead__c= testRecord.ID;
Insert testRecord5;
Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
testRecord6.Name = 'test';
testRecord6.Lead__c= testRecord.ID;
insert testRecord6 ;
Floor_Cleaning_Project_Over_View__c testRecord7 = new Floor_Cleaning_Project_Over_View__c();
testRecord7.Name = 'test';
testRecord7.Lead__c= testRecord.ID;
insert testRecord7;
General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
testRecord8.Name = 'test';
testRecord8.Lead__c= testRecord.ID;
insert testRecord8;
Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
testRecord9.Name = 'test';
testRecord9.Lead__c= testRecord.ID;
insert testRecord9 ;
Test.setCurrentPage(Page.addProposal);
System.currentPageReference().getParameters().put('id', testRecord.Id);
addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
addProposalCntrlTestIns.saveRecordlprop();
addProposalCntrlTestIns.saveRecordspropComm();
addProposalCntrlTestIns.saveRecordspropResd();
addProposalCntrlTestIns.saveRecordpprop1();
addProposalCntrlTestIns.saveRecordpprop2();
addProposalCntrlTestIns.saveRecordpprop3();
}
private static void addAttachmentToParent(Id testRecord) {
}
}
Thank you!
- Chaim Rosenfeld 8
- November 13, 2019
- Like
- 0
- Continue reading or reply
How to save post method json response in to salesforce Account Field
Hello,
I have post method to store salesforce data to external system. In response i'm getting Id from that system. how to save that id in salesforce Account field (Client_id__c).
below is my code:
Account a = [SELECT Id,Name, Client_City__c,Payroll_Contact__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,State_Code__c,Phone__c,State__c, Contact_Name__c, Phone,(select Name from contacts),(select Name from location__r) from Account where id = '0012C00000LcvQn'] ;
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject();
gen.writeStringField('name',a.name);
gen.writeStringField('address_line_1',a.Client_Address__c);
gen.writeStringField('city',a.Client_City__c);
gen.writeStringField('state_code',a.State_Code__c );
gen.writeStringField('zip_code',a.Client_Zip__c );
gen.writeStringField('sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.contacts[0].Name);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.Payroll_Contact__c);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeEndObject();
String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
System.debug('Client Created Successfully: ' +
response.getStatusCode() + ' ' + response.getBody());
} else {
System.debug('Unable to create Client: ' +
response.getStatusCode() + ' ' + response.getBody());
}
Response Screen Shot
Here im getting Id:655, i need to store that id in salesforce.
I have post method to store salesforce data to external system. In response i'm getting Id from that system. how to save that id in salesforce Account field (Client_id__c).
below is my code:
Account a = [SELECT Id,Name, Client_City__c,Payroll_Contact__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,State_Code__c,Phone__c,State__c, Contact_Name__c, Phone,(select Name from contacts),(select Name from location__r) from Account where id = '0012C00000LcvQn'] ;
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject();
gen.writeStringField('name',a.name);
gen.writeStringField('address_line_1',a.Client_Address__c);
gen.writeStringField('city',a.Client_City__c);
gen.writeStringField('state_code',a.State_Code__c );
gen.writeStringField('zip_code',a.Client_Zip__c );
gen.writeStringField('sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.contacts[0].Name);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.Payroll_Contact__c);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeEndObject();
String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
System.debug('Client Created Successfully: ' +
response.getStatusCode() + ' ' + response.getBody());
} else {
System.debug('Unable to create Client: ' +
response.getStatusCode() + ' ' + response.getBody());
}
Response Screen Shot
Here im getting Id:655, i need to store that id in salesforce.
- Sai Theja
- May 03, 2019
- Like
- 0
- Continue reading or reply
How can we track failed records in batch apex?
How can we track failed records in batch apex? suppose we are updating 100000 records out of that 20000 records are failed so again I want to update only failed records.How can we achieve this?
Thanks
Thanks
- SFDC ROCK
- April 25, 2019
- Like
- 0
- Continue reading or reply
How to access field in object
I have this json string i am pulling in with the code below:
{"success":1,"statuscode":200,"data":[{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"}]}
The code in Developer Console:
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://domain.ext/test');
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> rows = (List<Object>) results.get('data');
for (Object row : rows) {
System.debug('TEST ' + row.kleur1);
}
}
This code produces an error: Line: 13, Column: 36
Variable does not exist: kleur1. Houw should I access the field 'kleur1' of the object row?
{"success":1,"statuscode":200,"data":[{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"}]}
The code in Developer Console:
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://domain.ext/test');
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> rows = (List<Object>) results.get('data');
for (Object row : rows) {
System.debug('TEST ' + row.kleur1);
}
}
This code produces an error: Line: 13, Column: 36
Variable does not exist: kleur1. Houw should I access the field 'kleur1' of the object row?
- Jan Revet
- April 25, 2019
- Like
- 0
- Continue reading or reply
Moving Apex Trigger From Sandbox To Production And Getting Error During Apex Testing
Hi
I am moving an Apex Trigger from Sandbox to Production and this is the error I am getting in the Apex Test:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 0120v000000TPT9AAO: [RecordTypeId]
Stack Trace: Class.RequireRejectionCommentTest.generateAndSubmitObject: line 166, column 1 Class.RequireRejectionCommentTest.testApprovalWithoutComment: line 49, column 1
It's telling me as the Salesforce Admin I do not have access to this record but I do I checked and I have access to these record types.
This is the code right here:
I think it might have to do with the way I reference the Record Type as an ID.
instead of referencing it as RecordTypeID how would I reference it by the RecordTypeName instead?
I am moving an Apex Trigger from Sandbox to Production and this is the error I am getting in the Apex Test:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 0120v000000TPT9AAO: [RecordTypeId]
Stack Trace: Class.RequireRejectionCommentTest.generateAndSubmitObject: line 166, column 1 Class.RequireRejectionCommentTest.testApprovalWithoutComment: line 49, column 1
It's telling me as the Salesforce Admin I do not have access to this record but I do I checked and I have access to these record types.
This is the code right here:
testBatchIS.add(new Case(Hours__c=15.12,RecordTypeId='0120v000000TPT9AAO',AccountId='0017000001XpguKAAR', Status='New',Concession_Category__c='Scope Change', Explanation_for_Business_Reason_Choice__c='stuff'));
I think it might have to do with the way I reference the Record Type as an ID.
instead of referencing it as RecordTypeID how would I reference it by the RecordTypeName instead?
- Lionel Kamdem
- April 24, 2019
- Like
- 0
- Continue reading or reply
Lightning component warning message
Hi,
I need to display a warning or error message on lightning page based on various logic from an apex class. This should be updated dynamically based on the different logic.
F.ex the apex class runs a check on a custom email field on the case record to check if the email exist in a contact related to the account. If it exist but no portal user is created for that account we should display a warning message as a lightning component. If custom email address does not match any contacts then there should be an error message.
How can we setup a dynamically error/warning message for this?
I need to display a warning or error message on lightning page based on various logic from an apex class. This should be updated dynamically based on the different logic.
F.ex the apex class runs a check on a custom email field on the case record to check if the email exist in a contact related to the account. If it exist but no portal user is created for that account we should display a warning message as a lightning component. If custom email address does not match any contacts then there should be an error message.
How can we setup a dynamically error/warning message for this?
- Øyvind Borgersen 10
- April 19, 2019
- Like
- 0
- Continue reading or reply
CreatedDate != LastModifiedDate In SOQL ?? Urgent.
Object: Lead/Account
SOQL is not working can anyone help me.
My Query: [SELECT ID, Name FROM LEAD WHERE CreatedDate != LastModifiedDate ];
Error: Unknown error parsing query
SOQL is not working can anyone help me.
My Query: [SELECT ID, Name FROM LEAD WHERE CreatedDate != LastModifiedDate ];
Error: Unknown error parsing query
- Prem Chauhan
- April 12, 2019
- Like
- 0
- Continue reading or reply
i got a task on trigger.i created an object called data and created two fields one is country a picklist and and fee.i want to give discount on fee base on country value.i am getting error as condition expression must be type of boolean:string .plz help
this is my code
trigger trg12 on data__c (before insert) {
list<data__c>stu=trigger.new;
for(data__c s:trigger.new){
if(s.country__c='usa') {
double p;
p=s.fee__c*0.2;
s.fee__c =s.fee__c - p;
}
}
trigger trg12 on data__c (before insert) {
list<data__c>stu=trigger.new;
for(data__c s:trigger.new){
if(s.country__c='usa') {
double p;
p=s.fee__c*0.2;
s.fee__c =s.fee__c - p;
}
}
- raja subbu 1
- December 10, 2018
- Like
- 0
- Continue reading or reply
apex method for wrapper class to improve
Hello,
I neeed help.
I created a vf page that show records. I have a method which puts the month of a date field of each record selected to the current month. I have noticed, however, that by selecting more than 40 records, the page gives an error on line 39 (update selectedBD). it takes a long time to process.
I maybe implement logic the wrong way? there is better way?
Can Someone help me?
Thanks
I neeed help.
I created a vf page that show records. I have a method which puts the month of a date field of each record selected to the current month. I have noticed, however, that by selecting more than 40 records, the page gives an error on line 39 (update selectedBD). it takes a long time to process.
public class SearchWithWrapperC { public Date StartDate {get;set;} public Date EndDate {get;set;} public List<WrapperClass> listBD {get;set;} public void loadData() { listBD = new List<WrapperClass>(); for(Billing_Detail__c cr : [Select Id,SF_Opportunity_Id__c,Account_Name__c,Billing_Detail__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate Order by Account_Name__c, Monthly_Forecast__c]){ listBD.add(new WrapperClass (cr, false)); } } public List<WrapperClass> getBilling() { if(listBD == null) { listBD = new List<WrapperClass>(); for(Billing_Detail__c cr : [Select Id,SF_Opportunity_Id__c,Account_Name__c,Billing_Detail__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate Order by Monthly_Forecast__c ]){ listBD.add(new WrapperClass (cr, false)); } } return listBD; } public PageReference processSelected() { Integer m = Date.Today().Month(); List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>(); for(WrapperClass bd: getBilling()){ if(bd.check_box== true){ selectedBD.add(bd.cs); } } for(Billing_Detail__c cs: selectedBD) { cs.Monthly_Forecast__c = Date.newinstance( cs.Monthly_Forecast__c.year() , m , cs.Monthly_Forecast__c.day() ); update selectedBD; System.debug('The value is: ' + cs.Monthly_Forecast__c ); } return null; } public class WrapperClass { public Billing_Detail__c cs {get; set;} public Boolean check_box {get; set;} public WrapperClass(Billing_Detail__c c, Boolean check_box){ this.cs = c; this.check_box = false; } } }
I maybe implement logic the wrong way? there is better way?
Can Someone help me?
Thanks
- Frank Carter
- October 26, 2018
- Like
- 0
- Continue reading or reply
Html email status(EmailMessage) record not created in production
i have sent Email Using the below code
Thanks
Ahmed Ansari
Lead ld = [select id, email, lastname from lead where id=:'00Q0r000001y0d6']; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTemplateId('00X0r000000E7C9'); // Html Template Id mail.setTargetObjectId(ld.Id); //Lead id Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
Thanks
Ahmed Ansari
- Ahmed Ansari 13
- March 16, 2020
- Like
- 0
- Continue reading or reply
Picklist in Lightning data table?
Dear Team ,
Greetings !!!
Please let me know can we use Picklist in Lightning data table in lightning component.
Thanks & Regards
Sachin Bhalerao
Greetings !!!
Please let me know can we use Picklist in Lightning data table in lightning component.
Thanks & Regards
Sachin Bhalerao
- Sachin Bhalerao 17
- November 15, 2019
- Like
- 0
- Continue reading or reply
Open Custom Lightning Component on Click of a standard save button
Hi All,
We have an requirement where we have to open a custom lightning component once we click on the standard save button in LEX.
If someone implemened the solution or have an idea please share.
Regards,
Abhinav Sharma
We have an requirement where we have to open a custom lightning component once we click on the standard save button in LEX.
If someone implemened the solution or have an idea please share.
Regards,
Abhinav Sharma
- Abhinav Sharma.
- November 15, 2019
- Like
- 0
- Continue reading or reply
Help with this code please!!
I am trying to get the current case record Id. I will be using this class in a trigger. Thank you!!!
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (Apex Pages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.currentPage().
getParameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Here are the errors I am receiving:
1) Unexpected token '.'.
2)Invalid character in identifier: Pages.StandardController
3)Invalid type: Apex
public class currentCaseRecord {
Case currentRecord;
public currentCaseRecord (Apex Pages.StandardController controller){
currentRecord = [Select Id FROM Case Where Id =:ApexPages.currentPage().
getParameters().get('id')];
}
public case getcurrentRecord(){
return currentRecord;
}
}
Here are the errors I am receiving:
1) Unexpected token '.'.
2)Invalid character in identifier: Pages.StandardController
3)Invalid type: Apex
- Abby Stocker
- November 13, 2019
- Like
- 0
- Continue reading or reply
Test class for Contoller's method which involve attachment insert
Hello, can anyone help me in this question, in this method i am some custom record as well as attachment, my test class is running for custom records but it gives error "System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]"
this is method's code ,
Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ;
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;
lprop.Current_Record_ID__c = lpdocument.ID;
upsert lprop;
PageReference p = new PageReference('/' + this.lprop.Id );
return p;
}
and this is my test class for this controller
@isTest
public class addProposalCntrltest2{
static testMethod void testMethod1() {
Lead testRecord= new Lead();
testRecord.LastName = 'test name ';
testRecord.Company = 'test company';
testRecord.Status = 'new';
testRecord.Credit_Limit_Amount__c = 12344;
insert testRecord;
Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
testRecord2.Name = 'test';
testRecord2.Lead__c= testRecord.ID;
insert testRecord2 ;
Blob lpfileBody = Blob.valueOf('Test Data');
Attachment attachment = new Attachment();
attachment.Name = 'Test Attachment for Parent';
attachment.ParentId = testRecord2.ID;
attachment.Body = lpfileBody;
insert attachment;
Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
testRecord3.Name = 'test';
testRecord3.Lead__c= testRecord.ID;
insert testRecord3;
Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
testRecord4.Name = 'test';
testRecord4.Lead__c= testRecord.ID;
insert testRecord4 ;
Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
testRecord5.Name = 'test';
testRecord5.Lead__c= testRecord.ID;
Insert testRecord5;
Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
testRecord6.Name = 'test';
testRecord6.Lead__c= testRecord.ID;
insert testRecord6 ;
Floor_Cleaning_Project_Over_View__c testRecord7 = new Floor_Cleaning_Project_Over_View__c();
testRecord7.Name = 'test';
testRecord7.Lead__c= testRecord.ID;
insert testRecord7;
General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
testRecord8.Name = 'test';
testRecord8.Lead__c= testRecord.ID;
insert testRecord8;
Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
testRecord9.Name = 'test';
testRecord9.Lead__c= testRecord.ID;
insert testRecord9 ;
Test.setCurrentPage(Page.addProposal);
System.currentPageReference().getParameters().put('id', testRecord.Id);
addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
addProposalCntrlTestIns.saveRecordlprop();
addProposalCntrlTestIns.saveRecordspropComm();
addProposalCntrlTestIns.saveRecordspropResd();
addProposalCntrlTestIns.saveRecordpprop1();
addProposalCntrlTestIns.saveRecordpprop2();
addProposalCntrlTestIns.saveRecordpprop3();
}
private static void addAttachmentToParent(Id testRecord) {
}
}
Thank you!
this is method's code ,
Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ;
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;
lprop.Current_Record_ID__c = lpdocument.ID;
upsert lprop;
PageReference p = new PageReference('/' + this.lprop.Id );
return p;
}
and this is my test class for this controller
@isTest
public class addProposalCntrltest2{
static testMethod void testMethod1() {
Lead testRecord= new Lead();
testRecord.LastName = 'test name ';
testRecord.Company = 'test company';
testRecord.Status = 'new';
testRecord.Credit_Limit_Amount__c = 12344;
insert testRecord;
Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
testRecord2.Name = 'test';
testRecord2.Lead__c= testRecord.ID;
insert testRecord2 ;
Blob lpfileBody = Blob.valueOf('Test Data');
Attachment attachment = new Attachment();
attachment.Name = 'Test Attachment for Parent';
attachment.ParentId = testRecord2.ID;
attachment.Body = lpfileBody;
insert attachment;
Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
testRecord3.Name = 'test';
testRecord3.Lead__c= testRecord.ID;
insert testRecord3;
Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
testRecord4.Name = 'test';
testRecord4.Lead__c= testRecord.ID;
insert testRecord4 ;
Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
testRecord5.Name = 'test';
testRecord5.Lead__c= testRecord.ID;
Insert testRecord5;
Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
testRecord6.Name = 'test';
testRecord6.Lead__c= testRecord.ID;
insert testRecord6 ;
Floor_Cleaning_Project_Over_View__c testRecord7 = new Floor_Cleaning_Project_Over_View__c();
testRecord7.Name = 'test';
testRecord7.Lead__c= testRecord.ID;
insert testRecord7;
General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
testRecord8.Name = 'test';
testRecord8.Lead__c= testRecord.ID;
insert testRecord8;
Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
testRecord9.Name = 'test';
testRecord9.Lead__c= testRecord.ID;
insert testRecord9 ;
Test.setCurrentPage(Page.addProposal);
System.currentPageReference().getParameters().put('id', testRecord.Id);
addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
addProposalCntrlTestIns.saveRecordlprop();
addProposalCntrlTestIns.saveRecordspropComm();
addProposalCntrlTestIns.saveRecordspropResd();
addProposalCntrlTestIns.saveRecordpprop1();
addProposalCntrlTestIns.saveRecordpprop2();
addProposalCntrlTestIns.saveRecordpprop3();
}
private static void addAttachmentToParent(Id testRecord) {
}
}
Thank you!
- Chaim Rosenfeld 8
- November 13, 2019
- Like
- 0
- Continue reading or reply
Is Named Credentials are mandate to pass AppExchange security check?
Hi,
I have integrated Salesforce with 3rd party tool where it accepts basic authentication, For that, I have stored my credentials in custom settings and used from it.
I'm finding Named Crenedtial issue when I run PMD Code Analysis. Can anyone kindly say is that fine or should I implement Named Credentials?
I have integrated Salesforce with 3rd party tool where it accepts basic authentication, For that, I have stored my credentials in custom settings and used from it.
I'm finding Named Crenedtial issue when I run PMD Code Analysis. Can anyone kindly say is that fine or should I implement Named Credentials?
- Anurag Reddy Kanchimireddy
- November 13, 2019
- Like
- 0
- Continue reading or reply
not updating exsting values
My trigger is not working on exsting values
can any one plase help me
can any one plase help me
- Sayyad Amjad 7
- November 13, 2019
- Like
- 0
- Continue reading or reply
How to save post method json response in to salesforce Account Field
Hello,
I have post method to store salesforce data to external system. In response i'm getting Id from that system. how to save that id in salesforce Account field (Client_id__c).
below is my code:
Account a = [SELECT Id,Name, Client_City__c,Payroll_Contact__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,State_Code__c,Phone__c,State__c, Contact_Name__c, Phone,(select Name from contacts),(select Name from location__r) from Account where id = '0012C00000LcvQn'] ;
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject();
gen.writeStringField('name',a.name);
gen.writeStringField('address_line_1',a.Client_Address__c);
gen.writeStringField('city',a.Client_City__c);
gen.writeStringField('state_code',a.State_Code__c );
gen.writeStringField('zip_code',a.Client_Zip__c );
gen.writeStringField('sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.contacts[0].Name);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.Payroll_Contact__c);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeEndObject();
String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
System.debug('Client Created Successfully: ' +
response.getStatusCode() + ' ' + response.getBody());
} else {
System.debug('Unable to create Client: ' +
response.getStatusCode() + ' ' + response.getBody());
}
Response Screen Shot
Here im getting Id:655, i need to store that id in salesforce.
I have post method to store salesforce data to external system. In response i'm getting Id from that system. how to save that id in salesforce Account field (Client_id__c).
below is my code:
Account a = [SELECT Id,Name, Client_City__c,Payroll_Contact__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,State_Code__c,Phone__c,State__c, Contact_Name__c, Phone,(select Name from contacts),(select Name from location__r) from Account where id = '0012C00000LcvQn'] ;
JSONGenerator gen = JSON.createGenerator(true);
gen.writeStartObject();
gen.writeStringField('name',a.name);
gen.writeStringField('address_line_1',a.Client_Address__c);
gen.writeStringField('city',a.Client_City__c);
gen.writeStringField('state_code',a.State_Code__c );
gen.writeStringField('zip_code',a.Client_Zip__c );
gen.writeStringField('sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.contacts[0].Name);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();
gen.writeObjectField('name', a.Payroll_Contact__c);
gen.writeObjectField('phone', a.Phone__c);
gen.writeEndObject();
gen.writeEndObject();
String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
System.debug('Client Created Successfully: ' +
response.getStatusCode() + ' ' + response.getBody());
} else {
System.debug('Unable to create Client: ' +
response.getStatusCode() + ' ' + response.getBody());
}
Response Screen Shot
Here im getting Id:655, i need to store that id in salesforce.
- Sai Theja
- May 03, 2019
- Like
- 0
- Continue reading or reply
Is any another way to call future method in batch apex?
Is any another way to call future method in batch apex? As we know that we can not call from one asynchronous process from another asynchronous process.
- SFDC ROCK
- April 25, 2019
- Like
- 0
- Continue reading or reply
How can we track failed records in batch apex?
How can we track failed records in batch apex? suppose we are updating 100000 records out of that 20000 records are failed so again I want to update only failed records.How can we achieve this?
Thanks
Thanks
- SFDC ROCK
- April 25, 2019
- Like
- 0
- Continue reading or reply
How to access field in object
I have this json string i am pulling in with the code below:
{"success":1,"statuscode":200,"data":[{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"}]}
The code in Developer Console:
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://domain.ext/test');
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> rows = (List<Object>) results.get('data');
for (Object row : rows) {
System.debug('TEST ' + row.kleur1);
}
}
This code produces an error: Line: 13, Column: 36
Variable does not exist: kleur1. Houw should I access the field 'kleur1' of the object row?
{"success":1,"statuscode":200,"data":[{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"},{"kleur1":"rood","kleur2":"wit","kleur3":"blauw"}]}
The code in Developer Console:
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://domain.ext/test');
request.setMethod('GET');
HttpResponse response = http.send(request);
if (response.getStatusCode() == 200) {
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> rows = (List<Object>) results.get('data');
for (Object row : rows) {
System.debug('TEST ' + row.kleur1);
}
}
This code produces an error: Line: 13, Column: 36
Variable does not exist: kleur1. Houw should I access the field 'kleur1' of the object row?
- Jan Revet
- April 25, 2019
- Like
- 0
- Continue reading or reply
Moving Apex Trigger From Sandbox To Production And Getting Error During Apex Testing
Hi
I am moving an Apex Trigger from Sandbox to Production and this is the error I am getting in the Apex Test:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 0120v000000TPT9AAO: [RecordTypeId]
Stack Trace: Class.RequireRejectionCommentTest.generateAndSubmitObject: line 166, column 1 Class.RequireRejectionCommentTest.testApprovalWithoutComment: line 49, column 1
It's telling me as the Salesforce Admin I do not have access to this record but I do I checked and I have access to these record types.
This is the code right here:
I think it might have to do with the way I reference the Record Type as an ID.
instead of referencing it as RecordTypeID how would I reference it by the RecordTypeName instead?
I am moving an Apex Trigger from Sandbox to Production and this is the error I am getting in the Apex Test:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 0120v000000TPT9AAO: [RecordTypeId]
Stack Trace: Class.RequireRejectionCommentTest.generateAndSubmitObject: line 166, column 1 Class.RequireRejectionCommentTest.testApprovalWithoutComment: line 49, column 1
It's telling me as the Salesforce Admin I do not have access to this record but I do I checked and I have access to these record types.
This is the code right here:
testBatchIS.add(new Case(Hours__c=15.12,RecordTypeId='0120v000000TPT9AAO',AccountId='0017000001XpguKAAR', Status='New',Concession_Category__c='Scope Change', Explanation_for_Business_Reason_Choice__c='stuff'));
I think it might have to do with the way I reference the Record Type as an ID.
instead of referencing it as RecordTypeID how would I reference it by the RecordTypeName instead?
- Lionel Kamdem
- April 24, 2019
- Like
- 0
- Continue reading or reply
Lightning component warning message
Hi,
I need to display a warning or error message on lightning page based on various logic from an apex class. This should be updated dynamically based on the different logic.
F.ex the apex class runs a check on a custom email field on the case record to check if the email exist in a contact related to the account. If it exist but no portal user is created for that account we should display a warning message as a lightning component. If custom email address does not match any contacts then there should be an error message.
How can we setup a dynamically error/warning message for this?
I need to display a warning or error message on lightning page based on various logic from an apex class. This should be updated dynamically based on the different logic.
F.ex the apex class runs a check on a custom email field on the case record to check if the email exist in a contact related to the account. If it exist but no portal user is created for that account we should display a warning message as a lightning component. If custom email address does not match any contacts then there should be an error message.
How can we setup a dynamically error/warning message for this?
- Øyvind Borgersen 10
- April 19, 2019
- Like
- 0
- Continue reading or reply
CreatedDate != LastModifiedDate In SOQL ?? Urgent.
Object: Lead/Account
SOQL is not working can anyone help me.
My Query: [SELECT ID, Name FROM LEAD WHERE CreatedDate != LastModifiedDate ];
Error: Unknown error parsing query
SOQL is not working can anyone help me.
My Query: [SELECT ID, Name FROM LEAD WHERE CreatedDate != LastModifiedDate ];
Error: Unknown error parsing query
- Prem Chauhan
- April 12, 2019
- Like
- 0
- Continue reading or reply
how to restrict picklist value using validation rule
Hi,
If Account type(picklist) is "ABC" and while creating contact ,On contact the field type(picklist) should be "Operations" if we select any other except "operations" it should through an error.
Error Message : ABC account should have a contact type operations.
Please suggest.
If Account type(picklist) is "ABC" and while creating contact ,On contact the field type(picklist) should be "Operations" if we select any other except "operations" it should through an error.
Error Message : ABC account should have a contact type operations.
Please suggest.
- Mahesh sfdc 5
- April 12, 2019
- Like
- 0
- Continue reading or reply
Search bar Issue
Hey community,
I have a field named "Company Legal Name". It's a different name than account name. Its important that we seperate between account name and company legal name.
We switched to salesforce not to long ago. In our previous system, our employees used to search for the company legal name to identify a customer.
Is it possible to integrate the company legal name in the search bar?
At the moment its only searching for account names, contacts, opportunities.
Best regards,
Niki
- Tobias Klug
- April 11, 2019
- Like
- 0
- Continue reading or reply