Yogesh Sharma
IndividualForum Replies Created
-
Yogesh
MemberNovember 26, 2019 at 9:49 am in reply to: What type of relationship should be built for a one-to-one in Salesforce?Hello,
Here's an overview of the types of relationhips be Objects in Salesforce:
http://www.salesforce.com/us/developer/docs/api/Content/relationships_among_objects.htm (http://www.salesforce.com/us/developer/docs/api/Content/relationships_among_objects.htm" target="_blank) -
Yogesh
MemberNovember 26, 2019 at 9:30 am in reply to: Can we change the length of 'Opportunity Name' field in salesforce ?Hello,
We cannot change the Character Limit for Standard fields however there is a workaround to restrict the limit through Validation rule.
Workaround for above Example in Salesforce Classic:1) Click on Setup | Build | Customize | Accounts | Validation Rules.
a) Click New and enter Rule Name and Description.
b) Enter the Condition formula: LEN(Name) > 80
c) Enter Error Message - Account name should not exceed 80 characters.
d) Click on SaveIn the Lightning Experience:
2) Click on Setup | Object Manager | Accounts | Validation Rules.
a) Click New and enter Rule Name and Description.
b) Enter the Condition formula: LEN(Name) > 80
c) Enter Error Message - Account name should not exceed 80 characters.
d) Click on SaveNote: The character limit on any other Standard field can be restricted by using the sameValidation Rule, only the formula would differ based on the character limit to be restricted and the field name. The Formula for any other field would be:
LEN(FieldName) > number of characters to be restricted.
-
Yogesh
MemberNovember 26, 2019 at 9:22 am in reply to: How do you identify what field values changed for a record in APEX Triggers?Hello,
Here is the sample code:
trigger UpdateTriggerSample_tgr on Lead (after update) {
Lead NewLead = trigger.new[0]; Lead OldLead = trigger.old[0]; Lead LeadObject = new Lead(); // This takes all available fields from the required object. Schema.SObjectType objType = LeadObject.getSObjectType(); Map<String, Schema.SObjectField> M = Schema.SObjectType.Lead.fields.getMap(); for (String str : M.keyset()) { try { System.debug('Field name: '+str +'. New value: ' + NewLead.get(str) +'. Old value: '+OldLead.get(str)); if(NewLead.get(str) != OldLead.get(str)){ system.debug('******The value has changed!!!! '); // here goes more code } } catch (Exception e) { System.debug('Error: ' + e); } }
}
Thanks,
-
Yogesh
MemberNovember 22, 2019 at 7:57 am in reply to: What is the difference between getLimitQueryRows() and getQueryRows() in salesforce?Hello,
Limits.getQueryRows(): Returns the number of records that have been returned
by issuing SOQL queries.
Limits.getLimitQueryRows(): Returns the total number of records that can be
returned by issuing SOQL queries. This is the 50000 limit on the number of
rows that our code can cover. -
Yogesh
MemberNovember 22, 2019 at 7:54 am in reply to: How to create a child record from parent when external id is updated on parent record in Salesforce?Hello,
try this code below , hope it will help you :-
public static void syncInsuranceBuyers( List<BuyerWrapper> lstBuyers ) {
List<Account> lstBuyers = new List<Account>();
List<Contact> lstMembers = new List<Contact>();// Iterate over all the buyers to create a list for upserting the records
for( BuyerWrapper bw : lstBuyers ) {// Create a new instance of Account sObject and add it into the list
lstBuyers.add(
new Account(
Name = bw.name,
ERP_Id__c = bw.IdFromExternalSystem
// You can add addional fields mapping here
)
);// Iterate over the related members
for( MemberWrapper mw : bw.members ) {
// Create a new instance of Contact sObject and add it into the list
lstMembers.add(
new Contact(
FirstName = mw.firstName,
LastName = mw.lastName,
ERP_Id__c = mw.IdFromExternalSystem,
Account = new Account( ERP_Id__c = bw.IdFromExternalSystem )
// You can add addional fields mapping here
)
);
}
}// Will have to make 2 different DML calls as we need to specify the ExternID field
// which will be used to identify the existing records and will update themDatabase.UpsertResult[] resultsAcc = Database.upsert( lstBuyers, Account.Fields.ERP_Id__c );
Database.UpsertResult[] resultsCon = Database.upsert( lstMembers, Contact.Fields.ERP_Id__c );/****
* If it was just an insert opertaion then it could be achieved in a single DML
*
List<sObject> lstAllRecords = new List<sObject>();
lstAllRecords.addAll( lstBuyers );
lstAllRecords.addAll( lstMembers );
Database.SaveResult[] results = Database.insert( lstAllRecords );* Since, upsert DML operation requires an external ID field defination as an extra parameter and we have 2 different fields so above can't be
* achieved in a single DML call.
***/
} -
Yogesh
MemberNovember 22, 2019 at 7:43 am in reply to: How to use map inside a map in the json deserializeUntype in Salesforce without using class?Hello,
try this code below:-
{
"application_results": {
"permitted_deposit_sources": {
"@type": "AllowedValuesTestResult",
"result": "PASS",
"supplied_value": [
"SAVINGS",
"GIFT"
],
"test": "[?] in [SAVINGS, GIFT]"
},
"use_of_funds": {
"@type": "AllowedValuesTestResult",
"result": "PASS",
"supplied_value": [
"PURCHASE"
],
"test": "[?] in [PURCHASE]"
},
"maximum_number_applicants": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 1,
"test": "? <= 2"
}
},
"applicant1_results": {
"applicant_results": {
"max_retirement_age": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 70,
"test": "? <= 70"
},
"name_match": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == ? from CREDIT_REPORT",
"supplied_value": null
},
"minimum_income": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 50000,
"test": "? >= 15000"
},
"is_uk_tax_resident": {
"@type": "BooleanTestResult",
"result": "PASS",
"supplied_value": true,
"test": "? == true"
},
"minimum_age": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 34,
"test": "? >= 21"
},
"has_diplomatic_immunity": {
"@type": "BooleanTestResult",
"result": "PASS",
"supplied_value": false,
"test": "? == false"
},
"minimum_months_resident": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 25,
"test": "? >= 24"
},
"has_criminal_conviction": {
"@type": "BooleanTestResult",
"result": "PASS",
"supplied_value": false,
"test": "? == false"
},
"minimum_months_employment_history": {
"@type": "NumericTestResult",
"result": "PASS",
"supplied_value": 51,
"test": "? >= 3"
},
"permitted_residency_statuses": {
"@type": "AllowedValuesTestResult",
"result": "PASS",
"supplied_value": [
"UK_OR_EEA_NATIONAL"
],
"test": "[?] in [UK_NATIONAL, EEA_NATIONAL, UK_OR_EEA_NATIONAL, INDEFINITE_LEAVE_TO_REMAIN]"
}
},
"aml_results": {
"is_dead": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_forwarding_address": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"is_on_watchlist": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"is_on_cifas": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
}
},
"credit_results": {
"all_payments_up_to_date": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == true",
"supplied_value": null
},
"has_acceptable_discharged_ao": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not in [{ 0 within 100 years }]",
"supplied_value": null
},
"has_acceptable_discharged_iva": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not in [{ 0 within 100 years }]",
"supplied_value": null
},
"has_allowable_ccjs": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not { more than 0, within 6 years }",
"supplied_value": null
},
"has_undischarged_dro": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_allowable_defaults": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not [{ 0, within months 0-36 }, { 2, within months 37-72, totalling £1000 }]",
"supplied_value": null
},
"has_allowable_missed_payday_loan_pmts": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not [{ 0, within months 0-12 }, { 1, within months 13-36 }]",
"supplied_value": null
},
"has_had_property_repossessed": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_acceptable_discharged_dmp": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not in [{ 0 within 100 years }]",
"supplied_value": null
},
"has_undischarged_dmp": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_acceptable_discharged_bankruptcy": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not in [{ 0 within 100 years }]",
"supplied_value": null
},
"has_been_disqualified_director": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_allowable_missed_comms_pmts": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not [{ 0, within months 0-3 }, { 1, within months 4-12 }]",
"supplied_value": null
},
"has_undischarged_iva": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"has_acceptable_discharged_dro": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not in [{ 0 within 100 years }]",
"supplied_value": null
},
"has_allowable_missed_unsecured_loan_pmts": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not [{ 0, within months 0-12 }, { 1, within months 13-36 }]",
"supplied_value": null
},
"has_allowable_missed_secured_loan_pmts": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not { more than 1, within 3 years }",
"supplied_value": null
},
"has_undischarged_ao": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
},
"had_payday_loan": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "[?] not [{ 0, within months 0-12 }, { 1, within months 13-36, totalling £1000 }]",
"supplied_value": null
},
"has_undischarged_bankruptcy": {
"@type": "UntestedResult",
"result": "UNTESTED",
"test": "? == false",
"supplied_value": null
}
}
},
"applicant2_results": {
"applicant_results": {},
"aml_results": {},
"credit_results": {}
},
"property_results": {}
} -
Yogesh
MemberNovember 22, 2019 at 7:41 am in reply to: In which salesforce.com edition API's are not available?Hello,
API access is not normally supported in GE and PE orgs. However, after your app passes the security review, you’re eligible to use some APIs for building composite applications.
-
Yogesh
MemberNovember 20, 2019 at 6:44 am in reply to: How to use email service to import a CSV file attachment in Salesforce?Hello,
try this code below,hope it will help you:-
Global class CSVFileDataImportEmail implements Messaging.InboundEmailHandler
{
Global string nameFile{get;set;}
Global blob contentFile{get;set;}
String[] filelines = new String[]{};
Boolean processSheet = True;
List<Supplier_Capacity__c> SCupload;
List <Messaging.SingleEmailMessage> Mail = new List <Messaging.SingleEmailMessage>();
List <Messaging.SingleEmailMessage> Mails = new List <Messaging.SingleEmailMessage>();
Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.Inboundenvelope envelope)
{
nameFile = email.toString();
filelines = nameFile.split('n');
System.debug(' filelines... ' + filelines);
SCupload = new List<Supplier_Capacity__c>();
//Here I'm writing a map since I've 2 lookup fields
Map<String,String> SUP_map = New Map<String, String>();
Map<String,String> SH_map = New Map<String, String>();
String a1= '';
for(Account A:[Select Id,Name From Account])
{
System.debug(' ~Supplier~ ' + A.ID + A.Name);
SUP_map.put(A.Name,A.ID);
System.debug(' SUP_map ' + SUP_map);
System.debug(' SUP_mapID ' + SUP_map.get(A.ID) + ' SUP_mapName ' + SUP_map.get(A.Name));
}
for(Site__c S:[Select id, Site_Code__c From Site__c])
{
System.Debug(' <Ship From> '+ S.ID + S.Site_Code__c);
SH_map.put(S.Site_Code__c,S.ID);
System.debug(' SH_map ' + SH_map);
System.debug(' SH_mapID ' + SH_map.get(S.ID) + ' SH_mapName ' + SH_map.get(S.Site_Code__c));
}Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
System.debug(' >email< ' + email);
String fileAttachments = '';System.debug(' email attachments ' + email.TextAttachments);
Messaging.InboundEmail.textAttachment[] tAttachments = email.TextAttachments;
System.debug(' size of tAttachments ' + tAttachments.size() + 'Text Attachement from the email.' + tAttachments);
Messaging.InboundEmail.BinaryAttachment[] bAttachments = email.BinaryAttachments;
System.debug(' Binary Attachement from the email. ' + bAttachments);
String csvbody = '';
for(integer i=0; i < tAttachments.size(); i++)
{
System.debug(' attacments... ' + tAttachments[i]);
fileAttachments = String.valueOf(tAttachments[i]);
}
List<Supplier_Capacity__c> supc = new List<Supplier_Capacity__c>();List<String> badrows = new List<String>();
String csvBody1 = '';
String[] lineByCsvBody = new String[]{};
List<String> linebycsvdata = new List<String>();
If(tAttachments != Null && tAttachments.size() > 0)
{
For(Messaging.InboundEmail.textAttachment ttt : tAttachments)
{
csvBody1 = ttt.body;
lineByCsvBody = csvBody1.split('n');
System.debug('CSV BODY'+ csvBody1 + 'lines' +lineByCsvBody +' size of lineByCsvBody ' + lineByCsvBody.size() + ' This is a Text Attachment from the email parsed. ' + ttt);For(Integer j = 0; j < lineByCsvBody.size(); j++)
{
System.debug(' lineByCsvBody data...... ' + lineByCsvBody[j]);
If(j==0)
{
/*Here I'm checking and splitting the header values*/
String headerRow = lineByCsvBody[j];
System.debug(' headerRow DATA ... ' + headerRow);
String hvalue = csvbody1;
String[] headervalue = headerRow.split(',');
System.debug(' size of headervalue ' + headervalue.size());
System.debug(' headervalue1 '+ headervalue[0] + ' headervalue2 ' + headervalue[1]
+ ' headervalue3 ' + headervalue[2] + ' headervalue4 ' + headervalue[3]
+ ' headervalue5 ' + headervalue[4] + ' headervalue6 ' + headervalue[5]);if(headervalue[0] == Null || headervalue[0] == '' || headervalue[0].trim().length() < 1)
{
badrows.add('Column 1 : Supplier Column name is null.');
}
Else if(headervalue[0] != 'Supplier')
{
badrows.add('Column 1 : Supplier Column name should be accurate.');
}IF(headervalue[1] == Null || headervalue[1] == '' || headervalue[1].trim().length() < 1)
{
badrows.add('Column 2 : Ship From Column name is null.');
}
Else if(headervalue[1] != 'Ship From')
{
badrows.add('Column 2 : Ship From Column name should be accurate.');
}IF(headervalue[2] == Null || headervalue[2] == '' || headervalue[2].trim().length() < 1)
{
badrows.add('Column 3 : Capacity Column name is null.');
}
Else if(headervalue[2] != 'Capacity')
{
badrows.add('Column 3 : Capacity Column name should be accurate.');
}IF (headervalue[3] == Null || headervalue[3] == '' || headervalue[3].trim().length() < 1)
{
badrows.add('Column 4 : Lead Time Column name is null.');
}
Else if(headervalue[3] != 'Lead Time')
{
badrows.add('Column 4 : Lead Time Column name should be accurate.');
}IF (headervalue[4] == Null || headervalue[4] == '' || headervalue[4].trim().length() < 1)
{
badrows.add('Column 5 : Part unique to Buyer Column name is null.');
}
Else if(headervalue[4] != 'Part unique to Buyer')
{
badrows.add('Column 5 : Part unique to Buyer Column name should be accurate.');
}
String headervalue5=headervalue[5].trim();
System.debug('headervalue5 is '+ headervalue[5] +' for last row');
IF (headervalue[5] == Null || headervalue[5] == '' || headervalue[5].trim().length() < 1)
{
badrows.add('Column 6 : Shared Resource Column name is null.');
}
Else if(headervalue5 != 'Shared Resource')
{
System.debug('headervalue[5] '+ headervalue[5] + ' size... '+headervalue[5].length() + 'hardcode resource size ' + headervalue5.length());
badrows.add('Column 6 : Shared Resource Column name should be accurate.');
}System.debug(' badrows ' + badrows.size());
/*Here you can either put up your own result.message(Error Message) or messaging.singleemailmessage to send your own errror email*/
/*result.message = ('The following Column No: ' + badrows.size() + ' failed due to mismatching of header values in the csv parsed to the Email Service.');*/Messaging.SingleEmailMessage Errormail = new Messaging.SingleEmailMessage();
List <String> sendTo = new List <String>();
sendTo.add('[email protected]');
Errormail.setToAddresses(sendTo);Errormail.setReplyTo('[email protected]');
Errormail.setSenderDisplayName('Supplier Capacity');List <String> ccTo = new List <String>();
ccTo.add('[email protected]');
ccTo.add('[email protected]');
Errormail.setCcAddresses(ccTo);Errormail.setSubject('ERROR :: Failed to process Capacity Upload template (CSV)');
String body = '<html><body>Dear Supplier,' + '<br>' + '<br>' +'The Capacity Upload CSV Template failed to process because the below header values are missing in the sheet.' + '<br>' + '<br>';
if(badrows.size() > 0)
{
processSheet = false;
for(String str:badrows)
{
System.debug('value of str ' + str);
body += str + '<br>' +'<br>';
}
}
body += '<br>' + '<br>' + 'Correct the header columns and re-send for uploading again.'
+ '<br>' + 'Reach out to Admin for further assistance.'
+ '<br>' + '<br>' + '<br>' + '- Team.</body></html>';Errormail.setHtmlBody(body);
Mail.add(Errormail);
System.debug(' size of list ' + lineByCsvBody.size());
System.debug(' processSheet ' + processSheet);
if(badrows.size() > 0)
{
Messaging.sendEmail(Mail);
break;
}
}
if(j>0 && processSheet)
{
linebycsvdata.add(lineByCsvBody[j]);
System.debug('inside j>0'+linebycsvdata);
}
}
}
}
System.debug(' size of list ' + lineByCsvBody.size());
System.debug(' size of list of linebycsvdata ' + linebycsvdata.size());
System.debug(' processSheet ' + processSheet);
if( processSheet )
{
System.debug('inside insertion part ' + linebycsvdata.size());
Try
{integer rowCount=0;
for(String svalue:linebycsvdata)
{
/*Here I'm checking and splitting the values / data contained in the .csv file*/
rowCount++;
String[] splitvalue = svalue.split(',');
System.debug(' size of splitvalue ' + splitvalue.size());
Supplier_Capacity__c customobject = new Supplier_Capacity__c();
System.debug(' splitvalue1 ' + splitvalue[0] + ' splitvalue2 ' + splitvalue[1]
+ ' splitvalue3 ' + splitvalue[2] + ' splitvalue4 ' + splitvalue[3]
+ ' splitvalue5 ' + splitvalue[4] + ' splitvalue6 ' + splitvalue[5]);
if(splitvalue[0] == '' || splitvalue[0].trim().length() < 1 || splitvalue[0] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
if(splitvalue[1] == '' || splitvalue[1].trim().length() < 1 || splitvalue[1] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
if(splitvalue[2] == '' || splitvalue[2].trim().length() < 1 || splitvalue[2] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
if(splitvalue[3] == '' || splitvalue[3].trim().length() < 1 || splitvalue[3] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
if(splitvalue[4] == '' || splitvalue[4].trim().length() < 1 || splitvalue[4] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
if(splitvalue[5] == '' || splitvalue[5].trim().length() < 1 || splitvalue[5] == Null)
{
badrows.add('row number'+rowCount+' field value is missing');
continue;
}
String chk = SUP_map.get(splitvalue[0]);
String chk1 = SH_map.get(splitvalue[1]);
system.debug(' check_map ' + chk + splitvalue[0]);
system.debug(' check_map1 ' + chk1 + splitvalue[1]);customobject.Account__c = SUP_map.get(splitvalue[0]);
customobject.Ship_From__c = SH_map.get(splitvalue[1]);
customobject.Capacity__c = Decimal.valueof(splitvalue[2]);
customobject.Lead_Time__c = Decimal.valueof(splitvalue[3]);
customobject.Part_unique_to_Lear__c = Boolean.valueof(splitvalue[4]);
customobject.Shared_capacity__c = Boolean.valueof(splitvalue[5]);
insert customobject;
supc.add(customobject);
System.debug(' passed record size ' + supc.size());
}
For(string u:badrows)
{
a1 += u;
}
System.debug(' Badrows ' + a1);
result.success = true;
System.debug(' Result ' + result.success);
}
catch (Exception e)
{
System.debug(' Exception ' + e);
result.success = false;
System.debug(' Result ' + result.success);
}
Messaging.SingleEmailMessage SuccessMail = new Messaging.SingleEmailMessage();List <String> sendTo1 = new List <String>();
sendTo1.add('[email protected]');
SuccessMail.setToAddresses(sendTo1);SuccessMail.setReplyTo('[email protected]');
SuccessMail.setSenderDisplayName('Supplier Capacity');List <String> ccTo1 = new List <String>();
ccTo1.add('[email protected]');
ccTo1.add('[email protected]');
SuccessMail.setCcAddresses(ccTo1);SuccessMail.setSubject('Supplier Capacity Upload :: Success :: '+ supc.size() + ' records. ' + 'ERROR :: ' + badrows.size() + ' records.');
String body1 = '<html><body>Dear Supplier,' + '<br>' + '<br>' + 'Number of Records sucessfully processed :: '+ supc.size() + '<br>' + '<br>' + 'Number of Records failed to process :: ' + badrows.size() + '<br>' + '<br>' + '<br>' + '- Team.</body></html>';
/*result.message = ('The following number of records '+ supc.size() + ' got created successfuly by the Email Service and ' + '<br>' + a1 + ' number of records got failed by the Email Service.');*/SuccessMail.setHtmlBody(body1);
Mails.add(SuccessMail);
if(supc.size() > 0)
{
Messaging.sendEmail(Mails);
}
}
return result;
}
} -
Yogesh
MemberNovember 20, 2019 at 6:35 am in reply to: How to use static custom label in Salesforce lightning component?Hello,
Use the following syntax to access custom labels in Aura components.$Label.c.labelName for the default namespace
$Label.namespace.labelName if your org has a namespace, or to access a label in a managed package
You can reference custom labels in component markup and in JavaScript code. Here are some examples.Label in a markup expression using the default namespace
{!$Label.c.labelName} . -
Yogesh
MemberNovember 19, 2019 at 6:43 am in reply to: What is Customisation/non Declarative approach in Salesforce?Hello,
We live in a digital world. To keep up with employee and customer expectations, innovation through technology is increasingly becoming a nonnegotiable. Whether it’s a website to direct customers your way, an app to help improve their experience, or another project altogether, this naturally means that some kind of software development is needed.
To accomplish your goals, there are two types of programming you can turn to: imperative programming and declarative programming. Both have benefits, but how do you figure out which is best for you? First, it’s important to understand the difference between them.
Imperative programming, otherwise known as traditional or code-oriented programming, denotes the means of programming by using certain coding languages — such as C#, C++, Java, and so on — to tell a computer exactly how to perform an action. This requires a skilled developer with programming knowledge. This developer will build the application brick by brick using blocks of code, usually in a terminal window or some other highly specialized development environment.
On the other hand, declarative programming accomplishes the same results by basically telling the computer the end result and letting the computer figure out how to get there. In simpler terms, declarative programming denotes the kind of click or drag-and-drop solutions that allow someone without coding knowledge to build an application. The blocks of code are prewritten and packaged into components that you can just select as needed.
While there are certainly benefits of traditional imperative programming — experienced programmers prefer the freedom given by a more open source environment — most business leaders and entrepreneurs looking to create an application benefit from using those declarative programming drag-and-drop solutions.
-
Yogesh
MemberNovember 19, 2019 at 6:39 am in reply to: How to add select check box after displaying Lead and Contact records in visualforce page?Hello,
try this code below,I hope this will help you:-
Visulforce page code:
<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="test"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!contacts}" var="c" >
<apex:column >
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock id="test">
Total No of Selected Records :<apex:outputText value="{!value }"/>
<apex:pageBlockTable value="{!SelectedContacts}" var="c" >
<apex:column value="{!c.Name}" />
<apex:column value="{!c.Email}" />
<apex:column value="{!c.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>Apex Code:
public class wrapperClassController {
public List<cContact> contactList {get; set;}
public List<Contact> selectedContacts{get;set;}
public Integer value {get;set;}
public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]) {
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected() {
selectedContacts = new List<Contact>();
for(cContact cCon : getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
value = selectedContacts.size();
System.debug('printingtcontc'+selectedContacts.size());
return null;
}
public List<Contact> getSelectedContacts(){
System.debug('printingtcontc inside get'+selectedContacts.size());
if(selectedContacts.size()>0eturn selectedContacts;
else return null;
}
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}
public cContact(Contact c) {
con = c;
selected = false;
}
}
} -
Yogesh
MemberNovember 18, 2019 at 8:29 am in reply to: How to schedule a batch class without scheduler class in salesforce?Hello ,
you can get help from this code below:-
public class keepTruckInBatchForVehicleUpadte implements database.Batchable<decimal>, Database.AllowsCallouts, database.stateful, schedulable
{
public List<decimal> pageList;
public boolean executeNext;
public List<Vehicle_Update__c> lastvehicleUpdates;
public keepTruckInBatchForVehicleUpadte()
{
executeNext=false;
pageList = new List<decimal>();
}
public keepTruckInBatchForVehicleUpadte(List<decimal> counts, boolean bool)
{
executeNext = bool;
pageList = new List<decimal>();
pageList.addAll(counts) ;
}
public iterable<decimal> start(Database.BatchableContext BC)
{
return pageList;
}
public void execute(Database.BatchableContext BC, List<decimal> scope)
{
decimal count = scope[0];
keepTruckInApiCallouts.getVehicleLocations(count);
string returnResponse = keepTruckInApiCallouts.getVehicleLocations(count);
keepTruckInApiCallouts.keepTruckVehicleUpdate(returnResponse);
// Deserializes the returnResponse JSON string into collections of primitive data types.
Map<String, Object> jsonObjects = (Map<String, Object>) JSON.deserializeUntyped(returnResponse);
Map<String, Object> paginationobjs = (Map<String, Object>)jsonObjects.get('pagination');
decimal totalRecords = integer.valueof(paginationobjs.get('total'));
decimal perPageRecs = integer.valueof(paginationobjs.get('per_page'));
decimal totalPages = math.ceil(totalRecords/perPageRecs);
if(totalRecords > perPageRecs && executeNext == true)
{
pageList.clear();
for(count = 2; count <= totalPages; count++)
{
pageList.add(count);
}
}
else
{
executeNext = false;
}
}
public void finish(Database.BatchableContext BC)
{
if(executeNext == true)
{
database.executeBatch((new keepTruckInBatchForVehicleUpadte(pageList, false)),1);
}
}
public void execute(SchedulableContext SC)
{
lastVehicleUpdates = [select id from Vehicle_Update__c];
delete lastVehicleUpdates;
database.executebatch((new keepTruckInBatchForVehicleUpadte(new List<decimal>{1}, true)),1);
}
}
-
Yogesh
MemberNovember 18, 2019 at 8:25 am in reply to: What happens if some records do not meet the data validation cretaria when importing data?Hello,
Validation gets failed for such records and only these records don't get imported.
-
Yogesh
MemberNovember 15, 2019 at 6:06 am in reply to: How to insert a user using apex with a contact linked with it in Salesforce?Hello,
you can use this code below:-
User u = new User();
u.lastName = ‘Lstname’;
u.ContactId = contactLookup[0].Id;
u.Username = ‘username’;
u.Email = ’email’;
u.CommunityNickname = ‘nickname’;
u.Alias = ”;
u.TimeZoneSidKey = ‘America/Phoenix’; // Required
u.LocaleSidKey = ‘en_US’; // Required
u.EmailEncodingKey = ‘ISO-8859-1’; // Required
u.LanguageLocaleKey = ‘en_US’; // Required
}Hope it helps
-
Yogesh
MemberNovember 15, 2019 at 6:02 am in reply to: Can't Retrieve New Button Lightning overriden action on the Apex side in Salesforce?Hello,
Your component needs to implement lightning:actionOverride.please refer the below link for reference.https://success.salesforce.com/answers?id=9063A000000DoE9QAK
https://salesforce.stackexchange.com/questions/173298/overriding-standard-buttons-with-lightning-components
hope it helps. -
Hello,
One way would be to use Scheduled Apex that runs every so often, queries for ListViews and emails you whenever a new one is created. You'd need to track when the last time the job was run, perhaps using a custom setting, then see if any new list views have been created since the last run.
-
Yogesh
MemberNovember 13, 2019 at 6:55 am in reply to: How to get only First 5 records from api and enter them in salesforce as record?Hello,
Do simply add parameters and the values to limit your response in end point url in the callout class and by using json deserialize class method insert the records.
-
Hello,
simply insert instances of a contentVersion and a contentDocumentLink in a test class .
public class fileViewerCtrl {
@AuraEnabled
public static string insertDocument(string parentId, string dataContent) {
ContentVersion firstVersion = new ContentVersion();
firstVersion.versionData = blob.valueOf(dataContent);
firstVersion.title = parentId;
firstVersion.pathOnClient ='/testPath.txt';
insert firstVersion;ContentVersion fetchFirstVersion = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id =: firstVersion.Id];
ContentDocumentLink firstDocLink = new ContentDocumentLink();
firstDocLink.ContentDocumentId = fetchFirstVersion.ContentDocumentId;
firstDocLink.LinkedEntityId = parentId;
firstDocLink.ShareType = 'V';
insert firstDocLink;
string file = fetchContentDocument(fetchFirstVersion.ContentDocumentId);
system.debug('test'+file);
return file;
} -
Yogesh
MemberNovember 12, 2019 at 3:29 pm in reply to: What is recursive batch in Salesforce? How to do a recursive batch?Hello,
You can call batch from the previous batch finish() method. For example:-
public class RecursiveBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful {
private final Date passedDate;public RecursiveBatch(Date passedDate) {
this.passedDate = passedDate;
}public Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator( < QUERY >);
}public void execute(Database.BatchableContext BC, List<sObject> scope) {
}
public void finish(Database.BatchableContext BC) {
if(Date.today() <= this.passedDate) {
Database.executeBatch(new RecursiveBatch(passedDate.addDays(1)));
}
} -
Yogesh
MemberNovember 12, 2019 at 9:07 am in reply to: What is the maximum number of Components available on a Dashboard in Salesforce?Hello,
We can add upto 20 components in a single dashboard and every component can use single report. So it says we can add upto 20 reports in single dashboard.
Hope this answer would be helpful!!
-
Yogesh
MemberNovember 12, 2019 at 9:01 am in reply to: what type of report cannot be used to run a dashboard report in Salesforce and why?Hi,
DashBoard support Summary and Matrix report type and dash board support tabular also but tabular report if rows are limited (maximum 10).
Tabular Tabular reports are the simplest and fastest way to look at data. Similar to a spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed in a row. Tabular reports are best for creating lists of records or a list with a single grand total. They can't be used to create groups of data or charts, and can't be used in dashboards unless rows are limited. Examples include contact mailing lists and activity reports.
Summary Summary reports are similar to tabular reports, but also allow users to group rows of data, view subtotals, and create charts. They can be used as the source report for dashboard components. Use this type for a report to show subtotals based on the value of a particular field or when you want to create a hierarchical list, such as all opportunities for your team, subtotaled by Stage and Owner. Summary reports with no groupings show as tabular reports on the report run page.
Matrix Matrix reports are similar to summary reports but allow you to group and summarize data by both rows and columns.They can be used as the source report for dashboard components. Use this type for comparing related totals, especially if you have large amounts of data to summarize and you need to compare values in several different fields, or you want to look at data by date and by product, person, or geography. Matrix reports without at least one row and one column grouping show as summary reports on the report run page.
Watch Video Demo Building Matrix ReportsJoined Joined reports let you create multiple report blocks that provide different views of your data. Each block acts like a “sub-report,” with its own fields, columns, sorting, and filtering. A joined report can even contain data from different report types.
Watch Video Demo Introducing Joined Reports in Salesforce -
Yogesh
MemberNovember 11, 2019 at 8:08 am in reply to: Can two users have the same profile? Can two profiles be assigned to the same user in Salesforce?Hello,
Profiles determine the level of access a user can have in a Salesforce org.
As far as the first part of the question is concerned, Yes. One profile can be assigned to any number of users. Take the example of a Sales or Service team in a company. The entire team will be assigned the same profile. The admin can create one profile: Sales Profile, which will have access to the Leads, Opportunities, Campaigns, Contacts and other objects deemed necessary by the company.
In this way, many users can be assigned the same profile. In case the team lead or manager need access to additional records/ objects then it can be done by assigning permission sets only for those users.
Answering the second part of the question, each user can only be assigned 1 profile.
-
Yogesh
MemberNovember 11, 2019 at 8:02 am in reply to: Can you edit an apex trigger/ apex class in production environment? Can you edit a Visualforce page in Salesforce?Hello,
No, its not possible to edit apex classes and triggers directly on production:-
Only Developer Edition, Sandbox, and Trial organizations have the ability to create, edit, and delete Apex classes and triggers directly in the Salesforce CRM user interface. Unlimited Edition and Enterprise Edition production organizations can execute Apex and can view Apex in the user interface, but modifying Apex in the user interface is not allowed.
The Apex classes and triggers should first be written in a Developer Edition, Sandbox, or Trial organization along with the appropriate test methods that test at least 1% of triggers and 75% of classes. To deploy Apex into a production organization, a user with the Author Apex permission must deploy the triggers and classes using either the compileAndTest() or deploy() Metadata API methods which can be accessed with either the Apex Development Tool based on Apache ANT or the Force.com IDE based on Eclipse.
-
Yogesh
MemberNovember 8, 2019 at 1:17 pm in reply to: Is it possible to restrict permission for users using permission set in salesforce?Hello,
No, permission sets are used to grant additional access as opposed to remove acess. As a best practice, you want to start your org with the minimum access required, and then extend access to users as needed...not the other way around.
-
Yogesh
MemberNovember 8, 2019 at 12:58 pm in reply to: Can you please explain the 15 digit Id and 18 digit Id scenario in Salesforce?Hello,
The API can return either a case-sensitive or a case-insensitive ID field value.
The case-insensitive ID is identical to the 15-character case-sensitive ID, but with 3 extra characters appended to indicate the casing of each of the original 15 characters.
When inserting or updating records, the API accepts either the 15-character case-sensitive ID or the 18-character case-insensitive ID.
When querying or searching records using the API, you must specify a value of "1" for the "useCaseSafeIDs" parameter to indicate that you want the API to return case-insensitive IDs. If you don't specify the "useCaseSafeIDs" parameter, you automatically receive case-sensitive IDs.