You need to sign in to do that
Don't have an account?
Accounts plotted on Google Map with Lightning Component
I describe the codes below and hope anyone can help with the test code part. Thank you!
Component (MapNearbyAccount.cmp)
<aura:component controller="MapNearbyAccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId"> <aura:attribute name="mapMarkers" type="Object"/> <aura:attribute name="selectedMarkerValue" type="String" /> <aura:handler name="init" value="{! this }" action="{! c.init }"/> <div class="slds-box slds-theme--default"> <lightning:map mapMarkers="{! v.mapMarkers }" selectedMarkerValue="{!v.selectedMarkerValue}" markersTitle="accounts nearby" listView="auto" showFooter="false" onmarkerselect="{!c.handlerMarkerSelect}" /> </div> </aura:component>Controller (MapNearbyAccount.js)
({ init: function (cmp, event, helper) { var recordId = cmp.get("v.recordId"); var action = cmp.get("c.getAccounts"); action.setParams({recordId :recordId}); cmp.set('v.mapMarkers', [{location: {}}]); action.setCallback(this, function(response){ var accounts = response.getReturnValue(); var markers = []; for(var i = 0; i < accounts.length; i++){ var acc = accounts[i]; markers.push({ location: { Country : acc.BillingCountry, State : acc.BillingState, City: acc.BillingCity, Street: acc.BillingStreet }, icon : "standard:account", value: acc.Id, title: acc.Name, description:acc.Description }); } if(markers.length != 0){ cmp.set('v.mapMarkers', markers); } }); $A.enqueueAction(action); }, handlerMarkerSelect: function (cmp, event, helper) { console.log(event.getParam("selectedMarkerValue")); } });ApexClass (MapNearbyAccountController)
public class MapNearbyAccountController { @AuraEnabled public static List<Account> getAccounts(String BillingCity, String BillingState, String recordId){ Account acct = [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, Industry FROM Account WHERE Id =:recordId]; return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet,Description FROM Account WHERE BillingState = :acct.BillingState AND BillingCity LIKE :('%' + acct.BillingCity + '%') AND Industry = :acct.Industry LIMIT 10]; } }TestClass
@isTest public class MapNearbyAccountControllerTest { @isTest static void testMapNearbyAccountController() { Account acc1 = new Account(); acc1.Name='acc1'; acc1.BillingCity='Shibuya'; acc1.BillingState='Tokyo'; insert acc1; MapNearbyAccountController ctrl = new MapNearbyAccountController(); Test.startTest(); List<Account> getAccounts = ctrl.getAccounts(); System.assertEquals(false,getAccounts.isEmpty()); Test.stopTest(); } }

How Batch process works during the Error.
1. Assume a batch process has 3 iterations processing 200 records each. The batch process is doing an insert and I am using Database.Insert with AllorNone parameter set to False. Assume there was an error during the second iteration while processing 101 record.I understand that all the records in the first iteration will be committed and also the 100 records in the second iteration. My question is will the batch process continue to process other records in the second iteration and also the third iteration.
2. Assume all the 3 iterations (execute method) completed without any error but some error occured in the Finish method. Finish method just sends an email. How does this work, considering that I am using Database.Insert and AllorNone parameter set to False. My understanding is that all the records will be committed to the database but user will not be receiving email that the batch was successfull or not. I am confused how this scenario will work in the real time.

1. OK. The first execute method successfully processed records, and this records committed to the database.
The second execute method successfully processed too, because of the "Database.Insert" method without the AllOrNone parameter is not throwing an exception. This method returns the list of SaveResults records. It means that successfully inserted only 199 records(1 fail #101).
But if you use the insert method or the Database.insert with AllOrNone parameter the second execute method failed, and all inserted/updated records in the second "execute" method will be rollback. And exceptions did not stop process "execute" method; this means that after an exception in the second batch execute method; the third batch "execute" method will process.
2. You are right. The start, execute and finish methods process in an asynchronous mode, and if the finish method failed, no an email message received. After each successfully processed "execute" methods, all records will have to be committed to the database.
Thanks,
Alex

Does deploying profile through autorabbit deploy apex class and vf page access, other object access in salesforce?
2. Is there a way to assign apex classes to a profile through data loader?




You may have to add those apex classes and Vf pages in additional to the Profiles because the profile metadata only get the basic details of the profiles. If you need any additional access like field-level permissions or Object permissions or Apex Class Access you have to add those as well in the deployment.
Regarding the second question Did you try data loading on SetUpEntityAccess object?
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,

How to write Validation for URL ?
Hello Salesforce Experts,
Anyone please let me know how to write valition rule for URL ?
Else someone please provide regular expression string for URL ?
Thanks,



A small syntax change.
The following rule worked for me.
if(REGEX(URLfield__c,"^((http|https)://)??(www[.])??([a-zA-Z0-9]|-)+?([.][a-zA-Z0-9(-|/|=|?)??]+?)+?$"),false,true)
Hope this helps.
Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

How to remove comma from Number field
I have a number field (Number, 0) but when i put valuee 10000 in it it will diplay it as 10,000 i want to display it without comma.
I have selected number field because i need to select Max number from it and add 1 in Max number for new entry.
Can any body help me how i can do it.
Thanks,
Faraz

Create a new custom field, where type is "formula" and the formula return type is "text".
In the formula, use the TEXT() function, and pass the existing number field value into this formula. For example, if your number field is MyNumber_c then your formula would be: TEXT( MyNumber_c )
Your users will enter values into the existing number field, but you can use the formula field (which doesn't display thousands separators)
And don't forget to mark this answer as best, if answer this helps you :-)
--
Regards,
Grazitti Team
Web: www.grazitti.com

{Get; Set;} test method hello i write a test method for a controller.but i get only 71% code coverage. i am facing problem to write the test method for get set method.please help me here is my code
i write a test method for a controller.but i get only 71% code coverage.
i am facing problem to write the test method for get set method.please help me
here is my code:
public class eiException extends exception{
public String code{get; set;}
public String text{get; set;}
public String severity{get; set;}
public String category{get; set;}
public String subcategory{get; set;}
public String dataState{get; set;}
public Boolean retryAllowed{get; set;}
public String additionalInformation{get; set;}
public eiException(Dom.XmlNode node){
dom.XmlNode p;
p=node.getChildElement('code', eiEnvelope.namespace);
if(p != null){code = p.getText();}
p=node.getChildElement('text', eiEnvelope.namespace);
if(p != null){text = p.getText();}
p=node.getChildElement('severity', eiEnvelope.namespace);
if(p != null){severity = p.getText();}
p=node.getChildElement('category', eiEnvelope.namespace);
if(p != null){category = p.getText();}
p=node.getChildElement('subcategory', eiEnvelope.namespace);
if(p != null){subcategory = p.getText();}
p=node.getChildElement('dataState', eiEnvelope.namespace);
if(p != null){dataState = p.getText();}
p=node.getChildElement('retryAllowed', eiEnvelope.namespace);
if(p != null){retryAllowed = p.getText().equalsIgnoreCase('true');}
p=node.getChildElement('additionalInformation', eiEnvelope.namespace);
if(p != null){additionalInformation = p.getText();}
}
public static testmethod void testeiException() {
DOM.Document doc = new DOM.Document();
dom.XmlNode envelope= doc.createRootElement('Envelope',null,null);
dom.XmlNode body= envelope.addChildElement('code', null, null);
eiException eiEx = new eiException(body);
}
}


To achieve more test coverage for your eiException class, you need to add test methods to cover the getter and setter methods. Here is an example of how you can test these methods:
@isTest
static void testGettersAndSetters() {
eiException ex = new eiException();
ex.code = '123';
ex.text = 'Test Exception';
ex.severity = 'Error';
ex.category = 'General';
ex.subcategory = 'Unknown';
ex.dataState = 'Invalid';
ex.retryAllowed = true;
ex.additionalInformation = 'Additional info';
System.assertEquals('123', ex.code);
System.assertEquals('Test Exception', ex.text);
System.assertEquals('Error', ex.severity);
System.assertEquals('General', ex.category);
System.assertEquals('Unknown', ex.subcategory);
System.assertEquals('Invalid', ex.dataState);
System.assertEquals(true, ex.retryAllowed);
System.assertEquals('Additional info', ex.additionalInformation);
}
This test method creates an instance of the eiException class and sets values for all the properties using the getter and setter methods. Then it uses the System.assertEquals method to verify that the values are set correctly.
Note that you may need to update your eiException constructor to include an empty constructor to initialize the properties before the setter methods are called. You can do this by adding the following code:
public eiException() {
// Initialize properties
code = '';
text = '';
severity = '';
category = '';
subcategory = '';
dataState = '';
retryAllowed = false;
additionalInformation = '';
}
If you find this answer helpful, please mark it as the best answer.

How do you use a date in apex
This is my code
trigger CaseTrigger on Case (before update) {
for(Case cases: Trigger.new){
if(cases.stopped_time__c != null){
cases.Total_amount_of_time_in_Hours__c= (DateTime.now()-cases.stopped_time__c );
}
}
}


cases.Total_amount_of_time_in_Hours__c= (DateTime.now().getTime()-cases.ClosedDate.getTime() )/(1000.0 * 60.0 * 60.0);
In this code, we use the getTime method to convert the DateTime objects to the number of milliseconds, and then divide that number by the number of milliseconds in an hour to get the total number of hours.
I hope this will help.
Thanks
Why i can't Find My Custom Object in Lightning App?
Your help is highly appreciated
Fiona

First you need to create a tab for object, steps are given below :
Go to setup->App Setup->Create->Tabs->Click on New button
Now you are able to add this tab to application, steps are given below :
Go to setup-> App Setup-> Create-> Apps-> Click on your application->click on edit button-> select & add your tab
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh

access first element in a set
How can I access the first element in a set? Example in a list, you can use this to get the first element in the list
Integer x = xList.get(0);
What would be a quick equivalent way of doing this in a set?



string firstElement = null; for (string setElement : setElements) { firstElement = setElement; break; }
This would be (marginally) faster, since you break early.
You can also:
string firstelement = (new list<string>(setelements) )[0] );
Just make sure setElements.isEmpty() is false.

Apex Test Classes: "Attempt to de-reference a null object" error
System.DmlException: Update failed. First exception on row 0 with id 003M000000Zc1NaIAJ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopulateContactAreaCode: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.PopulateContactAreaCode: line 5, column 1: []
Trigger:
trigger PopulateContactAreaCode on Contact (before insert, before update) { for(Contact contact : Trigger.new) { string AreaCode = CountryRegion__c.getInstance(contact.MailingCountry).Area_Code__c; contact.Area_Code__c = AreaCode; } }
test class:
@isTest public class PopulateContactAreaCodeTest { static testMethod void attTriggerTest1() { test.startTest(); Account acct = new Account(id = '001M000000iLhTL', Name = 'Test Account ', Mailing_Country__c = 'Afghanistan'); update acct; Contact con = new Contact(id = '003M000000Zc1Na', LastName = 'Test Contact', Account = acct, Email = 'test@test.com', Mailing_Country__c = 'Afghanistan', MailingCountry = 'Afghanistan'); update con; delete con; test.stopTest(); } }
any idea what I added wrong?
thank you in advance

Because you're running a unit test, it doesn't see any data, and therefore no custom settings exist. You'll need to insert the custom setting before you insert the Contact record. Here's an example:
static testMethod void attTriggerTest1() { insert new CountryRegion__c(Name='Afghanistan',Area_Code__c='123'); test.startTest(); Account acct = new Account(id = '001M000000iLhTL', Name = 'Test Account ', Mailing_Country__c = 'Afghanistan'); update acct; Contact con = new Contact(id = '003M000000Zc1Na', LastName = 'Test Contact', Account = acct, Email = 'test@test.com', Mailing_Country__c = 'Afghanistan', MailingCountry = 'Afghanistan'); update con; delete con; test.stopTest(); }
Please use the below test class:
Thanks,
Maharajan.C