-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
8Questions
-
15Replies
QuoteDiscountApproval_TestunitTest1 and QuoteGroupDiscountApproval_TestunitTest1
Hi Team,
i am getting the below error when deploying into the production environment.
there are 2 test cases thats is getting failed when i am trying to deploy the code to the production. below u can find the error log.
QuoteDiscountApproval_TestunitTest1System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Stack Trace: Class.QuoteApprovalProcess.quoteProcess: line 16, column 1
new messages
4:43
QuoteGroupDiscountApproval_TestunitTest1System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Stack Trace: Class.QuoteApprovalProcess.quoteProcess: line 16, column 1
below is my Apex code that i am deploying to production,
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String ownerId,String accountName, String accountManager,String parentAccount,String website,
String companyCode,String atsOrHris, String accountSetUpFee,
String type,Decimal annualRevenue,String revenueStream,
boolean serviceLevelAgrmnt,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,String dunsNumber,String lineOfBus,String subType,String lastName,String euaBody,
String contentType,String attachName,String firstName, String title, String phone, String homePhone,
String fax, String email,String others,String[] amzDetails) {
Account restAcc = new Account(
OwnerId=ownerId,
Name=accountName,
Account_Manager__c=accountManager,
ParentId=parentAccount,
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
Account_Status__c='active',
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualRevenue,
Revenue_Stream__c = revenueStream,
Service_Level_Agreement__c = serviceLevelAgrmnt,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingStreet=billingStreet,
ShippingCity= billingCity,
ShippingState=billingState,
ShippingPostalCode=billingZip,
ShippingCountry=billingCountry,
D_U_N_S__c=dunsNumber,
//D_U_N_S_Number__c=dunsNumber,
Line_of_Business__c=lineOfBus,
ATS_Version__c=subType,
Other__c=others,
Amazon_Point_of_Contact__c=amzDetails[0],
Amazon_POC_Last_Name__c=amzDetails[1],
Amazon_POC_Email_Address__c= amzDetails[2]
);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.FirstName = firstName;
c.Title = title;
c.Phone = phone;
c.HomePhone=homePhone;
c.Fax =fax;
c.Email= email;
c.AccountId = restAcc.Id;
insert c;
Attachment attch= new Attachment();
//attch.Name=attachName +'.pdf';
attch.Name=attachName;
euaBody = euaBody.replaceall('src','alt');
attch.Body=blob.toPDF(euaBody);
//attch.Body = Blob.valueOf(sstr);
attch.ParentId =restAcc.Id;
//attachmentPdf.body = blob.toPDF(pdfContent);
insert attch;
//Document doc = new Document();
//doc.Name = 'SF_Dashboard.pdf';
//doc.body = bodyPage;
//doc.folderId = '00l6F000001pq8s'; //your folder id
//doc.IsPublic = true;
//doc.Description = 'Salesforce Dashboard Report -' + String.valueOf(date.today().format());
//insert doc;
//insert doc;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=billingStreet,ShippingCity= billingCity,ShippingState=billingState,
ShippingPostalCode=billingPostalCode,ShippingCountry=billingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
i am getting the below error when deploying into the production environment.
there are 2 test cases thats is getting failed when i am trying to deploy the code to the production. below u can find the error log.
QuoteDiscountApproval_TestunitTest1System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Stack Trace: Class.QuoteApprovalProcess.quoteProcess: line 16, column 1
new messages
4:43
QuoteGroupDiscountApproval_TestunitTest1System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Stack Trace: Class.QuoteApprovalProcess.quoteProcess: line 16, column 1
below is my Apex code that i am deploying to production,
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String ownerId,String accountName, String accountManager,String parentAccount,String website,
String companyCode,String atsOrHris, String accountSetUpFee,
String type,Decimal annualRevenue,String revenueStream,
boolean serviceLevelAgrmnt,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,String dunsNumber,String lineOfBus,String subType,String lastName,String euaBody,
String contentType,String attachName,String firstName, String title, String phone, String homePhone,
String fax, String email,String others,String[] amzDetails) {
Account restAcc = new Account(
OwnerId=ownerId,
Name=accountName,
Account_Manager__c=accountManager,
ParentId=parentAccount,
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
Account_Status__c='active',
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualRevenue,
Revenue_Stream__c = revenueStream,
Service_Level_Agreement__c = serviceLevelAgrmnt,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingStreet=billingStreet,
ShippingCity= billingCity,
ShippingState=billingState,
ShippingPostalCode=billingZip,
ShippingCountry=billingCountry,
D_U_N_S__c=dunsNumber,
//D_U_N_S_Number__c=dunsNumber,
Line_of_Business__c=lineOfBus,
ATS_Version__c=subType,
Other__c=others,
Amazon_Point_of_Contact__c=amzDetails[0],
Amazon_POC_Last_Name__c=amzDetails[1],
Amazon_POC_Email_Address__c= amzDetails[2]
);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.FirstName = firstName;
c.Title = title;
c.Phone = phone;
c.HomePhone=homePhone;
c.Fax =fax;
c.Email= email;
c.AccountId = restAcc.Id;
insert c;
Attachment attch= new Attachment();
//attch.Name=attachName +'.pdf';
attch.Name=attachName;
euaBody = euaBody.replaceall('src','alt');
attch.Body=blob.toPDF(euaBody);
//attch.Body = Blob.valueOf(sstr);
attch.ParentId =restAcc.Id;
//attachmentPdf.body = blob.toPDF(pdfContent);
insert attch;
//Document doc = new Document();
//doc.Name = 'SF_Dashboard.pdf';
//doc.body = bodyPage;
//doc.folderId = '00l6F000001pq8s'; //your folder id
//doc.IsPublic = true;
//doc.Description = 'Salesforce Dashboard Report -' + String.valueOf(date.today().format());
//insert doc;
//insert doc;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=billingStreet,ShippingCity= billingCity,ShippingState=billingState,
ShippingPostalCode=billingPostalCode,ShippingCountry=billingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
- Mahesh KG
- February 05, 2020
- Like
- 0
- Continue reading or reply
System.InvalidParameterValueException: An error occurred while parsing the input string
Hi Team,
When adding the pdf to the attachment, there is a src element in the image tag of my body. which is throwing the above error.
<img src="/resource/08146000000AiqO/logi" / >
when i replace the src with null, it is working fine. but i need the image in the pdf.
Can u help us fix this?
Thanks and Regards
Mahesh
When adding the pdf to the attachment, there is a src element in the image tag of my body. which is throwing the above error.
<img src="/resource/08146000000AiqO/logi" / >
when i replace the src with null, it is working fine. but i need the image in the pdf.
Can u help us fix this?
Thanks and Regards
Mahesh
- Mahesh KG
- December 05, 2019
- Like
- 0
- Continue reading or reply
Invalid number of parameters exceeds: 32
Hi Team,
Why is salesforce linting the parameters to 32?
How can i reslove this issue?
Why is salesforce linting the parameters to 32?
How can i reslove this issue?
- Mahesh KG
- November 15, 2019
- Like
- 0
- Continue reading or reply
How to save the attachment in pdf for an account
Hi Team,
Can you please help me saving the pdf document in Notes & Attachments section of the Account creation.
i am able to save the file but not as an pdf attachment. when i had set contenttype as application/pdf. the file is not getting opened.
Thanks and Regards
Mahesh
Can you please help me saving the pdf document in Notes & Attachments section of the Account creation.
i am able to save the file but not as an pdf attachment. when i had set contenttype as application/pdf. the file is not getting opened.
Thanks and Regards
Mahesh
- Mahesh KG
- November 11, 2019
- Like
- 0
- Continue reading or reply
How to Attach a file to Account Object
Hi Team,
Can you please help me in attaching a file to the Account Object.
i am able to create the account object with the below code i now need to attacha a file to the account object.
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String accountName,String accountOwner, String accountManager,String website,String companyCode,String atsOrHris, String accountSetUpFee,String accountStatus,String type,Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,String serviceLevelAgrmnt,String billingAddress,
String shippingAddress,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingZip,
String shippingCountry,String dunsNumber,String lineOfBus,String subType,String lastName) {
Account restAcc = new Account(
Name=accountName,
ParentId=accountOwner,Ac
count_Manager__c=accountManager,
// need to test website url field Id
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
AccountStatus_c=accountStatus,
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
ServiceLevelAgrmnt = serviceLevelAgrmnt,
BillingAddress=billingAddress,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingAddress=shippingAddress,
ShippingStreet=shippingStreet,
ShippingCity= shippingCity,
ShippingState=shippingState,
ShippingPostalCode=shippingZip,
ShippingCountry=shippingCountry,
DunsNumber=dunsNumber,
Line_of_Business__c=lineOfBus,
SubType=subType);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.AccountId = restAcc.Id;
insert c;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingPostalCode,
String shippingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=shippingStreet,ShippingCity= shippingCity,ShippingState=shippingState,
ShippingPostalCode=shippingPostalCode,ShippingCountry=shippingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
Thanks and Regards
Mahesh
Can you please help me in attaching a file to the Account Object.
i am able to create the account object with the below code i now need to attacha a file to the account object.
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String accountName,String accountOwner, String accountManager,String website,String companyCode,String atsOrHris, String accountSetUpFee,String accountStatus,String type,Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,String serviceLevelAgrmnt,String billingAddress,
String shippingAddress,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingZip,
String shippingCountry,String dunsNumber,String lineOfBus,String subType,String lastName) {
Account restAcc = new Account(
Name=accountName,
ParentId=accountOwner,Ac
count_Manager__c=accountManager,
// need to test website url field Id
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
AccountStatus_c=accountStatus,
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
ServiceLevelAgrmnt = serviceLevelAgrmnt,
BillingAddress=billingAddress,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingAddress=shippingAddress,
ShippingStreet=shippingStreet,
ShippingCity= shippingCity,
ShippingState=shippingState,
ShippingPostalCode=shippingZip,
ShippingCountry=shippingCountry,
DunsNumber=dunsNumber,
Line_of_Business__c=lineOfBus,
SubType=subType);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.AccountId = restAcc.Id;
insert c;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingPostalCode,
String shippingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=shippingStreet,ShippingCity= shippingCity,ShippingState=shippingState,
ShippingPostalCode=shippingPostalCode,ShippingCountry=shippingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
Thanks and Regards
Mahesh
- Mahesh KG
- September 27, 2019
- Like
- 0
- Continue reading or reply
how to attach a file to an account in java
Hi Team,
Can you please help me with the code for attaching a pdf file to the account i create.
i am creating account with the below code.
@HttpPost
global static ID createAccount(String name,String parent, String accountMgr,String setUpFee) {
Account restAcc = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee
);
insert restAcc;
return restAcc.Id;
}
i need to attach a pdf file to the above created account. i will be using java for creating the account.
Thanks in advance
Can you please help me with the code for attaching a pdf file to the account i create.
i am creating account with the below code.
@HttpPost
global static ID createAccount(String name,String parent, String accountMgr,String setUpFee) {
Account restAcc = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee
);
insert restAcc;
return restAcc.Id;
}
i need to attach a pdf file to the above created account. i will be using java for creating the account.
Thanks in advance
- Mahesh KG
- September 26, 2019
- Like
- 0
- Continue reading or reply
Create Account and link the Contact to the created Account
Hi Team,
can you help me linking the contact to the created account?
i have created a new APEX for creating an account. i need to create a contact and link the contact to the account.
Can you please help me with this.
i also tried creating the Seprate Contact object. but i need to know how to link Account to Contact.
can you help me linking the contact to the created account?
i have created a new APEX for creating an account. i need to create a contact and link the contact to the account.
Can you please help me with this.
i also tried creating the Seprate Contact object. but i need to know how to link Account to Contact.
- Mahesh KG
- September 25, 2019
- Like
- 0
- Continue reading or reply
How to Create an Account in Salesforce using REST API
Can you please let me know how to create an Account in Salesforce using the REST API.
i also need to know where i can find my clientId and Client Secret to get the access token
i also need to know where i can find my clientId and Client Secret to get the access token
- Mahesh KG
- August 29, 2019
- Like
- 0
- Continue reading or reply
System.InvalidParameterValueException: An error occurred while parsing the input string
Hi Team,
When adding the pdf to the attachment, there is a src element in the image tag of my body. which is throwing the above error.
<img src="/resource/08146000000AiqO/logi" / >
when i replace the src with null, it is working fine. but i need the image in the pdf.
Can u help us fix this?
Thanks and Regards
Mahesh
When adding the pdf to the attachment, there is a src element in the image tag of my body. which is throwing the above error.
<img src="/resource/08146000000AiqO/logi" / >
when i replace the src with null, it is working fine. but i need the image in the pdf.
Can u help us fix this?
Thanks and Regards
Mahesh
- Mahesh KG
- December 05, 2019
- Like
- 0
- Continue reading or reply
How to save the attachment in pdf for an account
Hi Team,
Can you please help me saving the pdf document in Notes & Attachments section of the Account creation.
i am able to save the file but not as an pdf attachment. when i had set contenttype as application/pdf. the file is not getting opened.
Thanks and Regards
Mahesh
Can you please help me saving the pdf document in Notes & Attachments section of the Account creation.
i am able to save the file but not as an pdf attachment. when i had set contenttype as application/pdf. the file is not getting opened.
Thanks and Regards
Mahesh
- Mahesh KG
- November 11, 2019
- Like
- 0
- Continue reading or reply
How to Attach a file to Account Object
Hi Team,
Can you please help me in attaching a file to the Account Object.
i am able to create the account object with the below code i now need to attacha a file to the account object.
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String accountName,String accountOwner, String accountManager,String website,String companyCode,String atsOrHris, String accountSetUpFee,String accountStatus,String type,Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,String serviceLevelAgrmnt,String billingAddress,
String shippingAddress,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingZip,
String shippingCountry,String dunsNumber,String lineOfBus,String subType,String lastName) {
Account restAcc = new Account(
Name=accountName,
ParentId=accountOwner,Ac
count_Manager__c=accountManager,
// need to test website url field Id
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
AccountStatus_c=accountStatus,
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
ServiceLevelAgrmnt = serviceLevelAgrmnt,
BillingAddress=billingAddress,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingAddress=shippingAddress,
ShippingStreet=shippingStreet,
ShippingCity= shippingCity,
ShippingState=shippingState,
ShippingPostalCode=shippingZip,
ShippingCountry=shippingCountry,
DunsNumber=dunsNumber,
Line_of_Business__c=lineOfBus,
SubType=subType);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.AccountId = restAcc.Id;
insert c;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingPostalCode,
String shippingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=shippingStreet,ShippingCity= shippingCity,ShippingState=shippingState,
ShippingPostalCode=shippingPostalCode,ShippingCountry=shippingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
Thanks and Regards
Mahesh
Can you please help me in attaching a file to the Account Object.
i am able to create the account object with the below code i now need to attacha a file to the account object.
@RestResource(urlMapping='/Account/*')
global with sharing class AccountManager {
@HttpGet
global static Account getAccountById() {
RestRequest request = RestContext.request;
// grab the caseId from the end of the URL
String accountId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Name
FROM Account
WHERE Id = :accountId];
return result;
}
@HttpPost
global static ID createAccount(String accountName,String accountOwner, String accountManager,String website,String companyCode,String atsOrHris, String accountSetUpFee,String accountStatus,String type,Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,String serviceLevelAgrmnt,String billingAddress,
String shippingAddress,String billingStreet,String billingCity, String billingState,String billingZip,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingZip,
String shippingCountry,String dunsNumber,String lineOfBus,String subType,String lastName) {
Account restAcc = new Account(
Name=accountName,
ParentId=accountOwner,Ac
count_Manager__c=accountManager,
// need to test website url field Id
Website=website,
Company_Code__c=companyCode,
ATS_or_HRIS__c=atsOrHris,
Account_Set_up_Fee__c=accountSetUpFee,
AccountStatus_c=accountStatus,
Type=type,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
ServiceLevelAgrmnt = serviceLevelAgrmnt,
BillingAddress=billingAddress,
BillingStreet=billingStreet,
BillingCity= billingCity,
BillingState=billingState,
BillingPostalCode=billingZip,
BillingCountry=billingCountry,
ShippingAddress=shippingAddress,
ShippingStreet=shippingStreet,
ShippingCity= shippingCity,
ShippingState=shippingState,
ShippingPostalCode=shippingZip,
ShippingCountry=shippingCountry,
DunsNumber=dunsNumber,
Line_of_Business__c=lineOfBus,
SubType=subType);
insert restAcc;
// Account a = [select Id, Name from Account where Name = ''Shaik'];
Contact c = new Contact();
c.LastName = lastName;
c.AccountId = restAcc.Id;
insert c;
return restAcc.Id;
}
@HttpDelete
global static void deleteCase() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Case thisCase = [SELECT Id FROM Case WHERE Id = :caseId];
delete thisCase;
}
@HttpPut
global static ID upsertCase(String name,String parent, String accountMgr,String setUpFee,String vendorType,
Decimal annualRevenue, Decimal annualAbRevenue, String revenueStream,
String billingStreet,String billingCity, String billingState,String billingPostalCode,
String billingCountry,
String shippingStreet,String shippingCity, String shippingState,String shippingPostalCode,
String shippingCountry) {
Account restAccUpdate = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee,
Type=vendorType,
AnnualRevenue=annualRevenue,
Annual_AB_Revenue__c= annualAbRevenue,
Revenue_Stream__c = revenueStream,
BillingStreet=billingStreet,BillingCity= billingCity,BillingState=billingState,
BillingPostalCode=billingPostalCode,BillingCountry=billingCountry,
ShippingStreet=shippingStreet,ShippingCity= shippingCity,ShippingState=shippingState,
ShippingPostalCode=shippingPostalCode,ShippingCountry=shippingCountry);
// Match case by Id, if present.
// Otherwise, create new case.
upsert restAccUpdate;
// Return the case ID.
return restAccUpdate.Id;
}
@HttpPatch
global static ID updateCaseFields() {
RestRequest request = RestContext.request;
String caseId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
Account thisCase = [SELECT Id FROM Account WHERE Id = :caseId];
// Deserialize the JSON string into name-value pairs
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
// Iterate through each parameter field and value
for(String fieldName : params.keySet()) {
// Set the field and value on the Case sObject
thisCase.put(fieldName, params.get(fieldName));
}
update thisCase;
return thisCase.Id;
}
}
Thanks and Regards
Mahesh
- Mahesh KG
- September 27, 2019
- Like
- 0
- Continue reading or reply
how to attach a file to an account in java
Hi Team,
Can you please help me with the code for attaching a pdf file to the account i create.
i am creating account with the below code.
@HttpPost
global static ID createAccount(String name,String parent, String accountMgr,String setUpFee) {
Account restAcc = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee
);
insert restAcc;
return restAcc.Id;
}
i need to attach a pdf file to the above created account. i will be using java for creating the account.
Thanks in advance
Can you please help me with the code for attaching a pdf file to the account i create.
i am creating account with the below code.
@HttpPost
global static ID createAccount(String name,String parent, String accountMgr,String setUpFee) {
Account restAcc = new Account(
Name=name,
ParentId=parent,
Account_Manager__c=accountMgr,
Account_Set_up_Fee__c=setUpFee
);
insert restAcc;
return restAcc.Id;
}
i need to attach a pdf file to the above created account. i will be using java for creating the account.
Thanks in advance
- Mahesh KG
- September 26, 2019
- Like
- 0
- Continue reading or reply
Create Account and link the Contact to the created Account
Hi Team,
can you help me linking the contact to the created account?
i have created a new APEX for creating an account. i need to create a contact and link the contact to the account.
Can you please help me with this.
i also tried creating the Seprate Contact object. but i need to know how to link Account to Contact.
can you help me linking the contact to the created account?
i have created a new APEX for creating an account. i need to create a contact and link the contact to the account.
Can you please help me with this.
i also tried creating the Seprate Contact object. but i need to know how to link Account to Contact.
- Mahesh KG
- September 25, 2019
- Like
- 0
- Continue reading or reply
How to Create an Account in Salesforce using REST API
Can you please let me know how to create an Account in Salesforce using the REST API.
i also need to know where i can find my clientId and Client Secret to get the access token
i also need to know where i can find my clientId and Client Secret to get the access token
- Mahesh KG
- August 29, 2019
- Like
- 0
- Continue reading or reply
How to integrate java and salesforce using rest api
Hello,
I am tring to connect java to salesforce by using rest api..
here i am attached the code,after running this code it throughs a exception
Code:-
import java.io.InputStreamReader;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.json.JSONObject;
import org.json.JSONTokener;
public class JavarestApi{
private static final String clientId="3MVG9d8..z.hDcPL3l_8qXSX5sPV_vOueBOIUnrKxsH0MQdtcD0r0H13mxvNTwXV4.mt8YX1unfFha68RuDor";
private static final String clientSecret="1958974945496795189";
private static final String redirectUrl="https://localhost:8443/RestTest/oauth/_callback";
private static String tokenUrl="";
private static final String environment="https://login.salesforce.com";
private static final String username="***********@gmail.com";
private static final String password="*****************************************"; //passwordsecurity token
private static String accessToken="";
private static String instanceUrl="";
public static void main(String ar[]){
System.out.println("----------getting a token---------");
tokenUrl=environment+"/services/oauth2/token";
System.out.println("tokenUrl ........."+tokenUrl);
HttpClient httpclient=new HttpClient();
//httpclient.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
httpclient.getParams().setParameter(HttpClientParams.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
PostMethod post=new PostMethod(tokenUrl);
post.addParameter("grant_type","password");
post.addParameter("client_id",clientId);
post.addParameter("client_secret",clientSecret);
post.addParameter("redirect_url",redirectUrl);
post.addParameter("username",username);
post.addParameter("password",password);
try{
httpclient.executeMethod(post);
JSONObject authResponse=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
System.out.println("Auth Response :-"+authResponse.toString(2));
accessToken=authResponse.getString("access_token");
instanceUrl=authResponse.getString("instance_url");
System.out.println("Got Access Token " +accessToken);
System.out.println("Got Instance Url " +instanceUrl);
new JavarestApi().createaccount(instanceUrl,accessToken);
}
catch(Exception e){
System.out.println("Exception during Connect"+e);
}
}
private String createaccount(String instanceUrl,String accessToken) throws Exception{
System.out.println("----------start account--------");
HttpClient httpclient=new HttpClient();
JSONObject account=new JSONObject();
String accountId="";
try{
account.put("Name", "Amol");
account.put("AccountNumber", "98123");
PostMethod post=new PostMethod(instanceUrl+"/services/data/v20.0/sobjects/Account/");
post.setRequestHeader("Authorization", "OAuth" +accessToken);
post.setRequestEntity(new StringRequestEntity(account.toString(),"application/x-www-form-urlencoded",null));
httpclient.executeMethod(post);
System.out.println("HTTP status"+post.getStatusCode()+"creating account\n\n");
if(post.getStatusCode() == HttpStatus.SC_CREATED ){
try{
JSONObject response=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
System.out.println("create response" + response.toString(2));
if(response.getBoolean("success")){
accountId=response.getString("id");
System.out.println("new record id:-" +accountId+"\n\n");
}
}catch(Exception e){
e.printStackTrace();
}
}
}
catch(Exception e){
e.printStackTrace();
}
System.out.println("----------end account--------");
return accountId;
}
}
Exception :-
----------getting a token---------
tokenUrl .........https://login.salesforce.com/services/oauth2/token
Auth Response :-{
"access_token": "00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX",
"signature": "GFMgzpOtCxO2UuPBqGh2SHogWMdx0mk6J6X30goaFRU=",
"instance_url": "https://ap5.salesforce.com",
"id": "https://login.salesforce.com/id/00D7F000001ZxXlUAK/0057F000000qvkHQAQ",
"token_type": "Bearer",
"issued_at": "1503479401122"
}
Got Access Token 00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX
Got Instance Url https://ap5.salesforce.com
----------start account--------
HTTP status401creating account
----------end account--------
Aug 23, 2017 5:09:59 AM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
WARNING: Unable to respond to any of these challenges: {token=Token}
$401unthorized http error
it not inserted the data into salesforce
I am tring to connect java to salesforce by using rest api..
here i am attached the code,after running this code it throughs a exception
Code:-
import java.io.InputStreamReader;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.json.JSONObject;
import org.json.JSONTokener;
public class JavarestApi{
private static final String clientId="3MVG9d8..z.hDcPL3l_8qXSX5sPV_vOueBOIUnrKxsH0MQdtcD0r0H13mxvNTwXV4.mt8YX1unfFha68RuDor";
private static final String clientSecret="1958974945496795189";
private static final String redirectUrl="https://localhost:8443/RestTest/oauth/_callback";
private static String tokenUrl="";
private static final String environment="https://login.salesforce.com";
private static final String username="***********@gmail.com";
private static final String password="*****************************************"; //passwordsecurity token
private static String accessToken="";
private static String instanceUrl="";
public static void main(String ar[]){
System.out.println("----------getting a token---------");
tokenUrl=environment+"/services/oauth2/token";
System.out.println("tokenUrl ........."+tokenUrl);
HttpClient httpclient=new HttpClient();
//httpclient.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
httpclient.getParams().setParameter(HttpClientParams.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
PostMethod post=new PostMethod(tokenUrl);
post.addParameter("grant_type","password");
post.addParameter("client_id",clientId);
post.addParameter("client_secret",clientSecret);
post.addParameter("redirect_url",redirectUrl);
post.addParameter("username",username);
post.addParameter("password",password);
try{
httpclient.executeMethod(post);
JSONObject authResponse=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
System.out.println("Auth Response :-"+authResponse.toString(2));
accessToken=authResponse.getString("access_token");
instanceUrl=authResponse.getString("instance_url");
System.out.println("Got Access Token " +accessToken);
System.out.println("Got Instance Url " +instanceUrl);
new JavarestApi().createaccount(instanceUrl,accessToken);
}
catch(Exception e){
System.out.println("Exception during Connect"+e);
}
}
private String createaccount(String instanceUrl,String accessToken) throws Exception{
System.out.println("----------start account--------");
HttpClient httpclient=new HttpClient();
JSONObject account=new JSONObject();
String accountId="";
try{
account.put("Name", "Amol");
account.put("AccountNumber", "98123");
PostMethod post=new PostMethod(instanceUrl+"/services/data/v20.0/sobjects/Account/");
post.setRequestHeader("Authorization", "OAuth" +accessToken);
post.setRequestEntity(new StringRequestEntity(account.toString(),"application/x-www-form-urlencoded",null));
httpclient.executeMethod(post);
System.out.println("HTTP status"+post.getStatusCode()+"creating account\n\n");
if(post.getStatusCode() == HttpStatus.SC_CREATED ){
try{
JSONObject response=new JSONObject(new JSONTokener (new InputStreamReader(post.getResponseBodyAsStream())));
System.out.println("create response" + response.toString(2));
if(response.getBoolean("success")){
accountId=response.getString("id");
System.out.println("new record id:-" +accountId+"\n\n");
}
}catch(Exception e){
e.printStackTrace();
}
}
}
catch(Exception e){
e.printStackTrace();
}
System.out.println("----------end account--------");
return accountId;
}
}
Exception :-
----------getting a token---------
tokenUrl .........https://login.salesforce.com/services/oauth2/token
Auth Response :-{
"access_token": "00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX",
"signature": "GFMgzpOtCxO2UuPBqGh2SHogWMdx0mk6J6X30goaFRU=",
"instance_url": "https://ap5.salesforce.com",
"id": "https://login.salesforce.com/id/00D7F000001ZxXlUAK/0057F000000qvkHQAQ",
"token_type": "Bearer",
"issued_at": "1503479401122"
}
Got Access Token 00D7F000001ZxXl!ARYAQBcTSXtZXdYDXFHlneUawyG9iqF6_dCTBPSbBCqrV6vSDPzzcNJesGFBS239x7p51xBAP4ZaqHOfgrmH7tZam2wTS3GX
Got Instance Url https://ap5.salesforce.com
----------start account--------
HTTP status401creating account
----------end account--------
Aug 23, 2017 5:09:59 AM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
WARNING: Unable to respond to any of these challenges: {token=Token}
$401unthorized http error
it not inserted the data into salesforce
- Rohini Gurav 2
- August 23, 2017
- Like
- 0
- Continue reading or reply