• Ankit Maini.
  • 108 Points
  • Member since 2014

  • Chatter
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
  • 36

I am new to Salesforce. I have look thru the list of API available in Salesforce.
I need to get the data in Account and Contact as following into my Java application:
User-added image
Any suggestion which API I should focus and start on?
  • February 06, 2015
  • Like
  • 0
Trying to deploy development from my sandbox using change sets. Whilst custom fields, tabs etc come across fine, the triggers are failing with the following error:

Code Coverage Failure Your organization's code coverage is 0%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

This means nothing to me and I'm just getting more confused looking through the help documents. I don't really do code and I don't know where to start. Any help would be very much appreciated
I have oveveride the stadard "New"  button with a component (Parent) and in that parent component there is a child component. In the child component I have a button and on that button click I am navigating it to the record detail page( Which is actually the "View" itself.
But navigation is not working ( As init method is not callling again of the Parent component)

ParentComponent (Overide on "New" button)
<aura:component implements="lightning:isUrlAddressable,lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes">
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <c:NavigationDemoView />

Parent COntroller
	init : function(component, event, helper) {

Child Component 
<aura:component implements="lightning:isUrlAddressable,lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes">
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
     <lightning:button name="s" onclick="{!c.navigateRecord}" value="click"  label="navigate to sobject"/>
Child COntroller:
	init : function( component, event, helper) {
       alert('child called');
     navigateRecord : function(component, event, helper) {
      	var navEvt = $A.get("e.force:navigateToSObject");
          "recordId": "a040I00002W6ryNQAR"

If I access the view of this record (a040I00002W6ryNQAR) and click on the buttton it will not reload init of my parent.

But if access different record and click on the button it will redirect to this(a040I00002W6ryNQAR) record.

So I am not able to understand that why I am not able to redirect to the same record again.

Note: Instead of navigateToSObject, I have used other options like navigateTOURL and calling another component and calling navigatrtosobject from there but nothing is working for the same recordID for which I am viewing the record.

Please suugest.

I have used force:inputField on a lighting component and pre-populate the WhatID. Before summer 19, pre-populate was working fine, but it stopped working in summer19. Any woraround for this?
Component Code:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="newTask" type="Task" default="{ 'sobjectType' : 'Task','Status':'Open', 'WhatId' : '' }" />

<div class="marginDiv forceInput">
       <div>Related To</div>
        <div><force:inputField aura:id="relatedTo" value="{!v.newTask.WhatId}"/></div>


doInit : function(component, event, helper) {
	var recId = component.get("v.recordId");
							var value = [{ 
							   type: 'My_Custom_Object__c', 
							   id: recId, 
							   label: "navigate", 
							   component.find("relatedTo").get("v.body")[0].set("v.values", value); 


There is strange thing happening, I have a logic in a apex class to convert the lead(via visualforce page), When Lead is pending for approval process it gives me an error:
User-added image

This is correct because if lead is pending from approval we can not convert it.

Now if I go to that lead and "Approve"(No other approval is pedning) that lead and test again through vf page still it shows the same error.

NOW if I go to that lead  detail page and click on "Convert" button it shows me this page:
User-added image

After this I don't click on convert, I just go to the vf page and try to convert through apex class, and it converted succefully. SO I am not sure what is happening ?  Why my lead is not getting converted even I approve/reject , Is there any workaround of this? Please suggest.
I have a site with multiple pages and I am using request forwarding rather than sendRedirect, that means sendRedirect(false).
There's some weirdness where when an applicant goes to the next page, it loads the next page (correctly), but the URL up at the top of the browser still shows the URL value from the previous page (even though you are looking at the content from the next page).

I don't want to use the sendRedirect(false), Is there any solution to show correct URL when using sendRedirect(false)/Request Forwarding
How to assigned a record to a different user?
  • I have a custom object Board__c
  • and a custom field Assigned_To__c(lookup to users from other profiles).
  • Assigned users see only those records which they are assigned.
  • I will answer on this post after if I done it. 
I have a scenario where if we insert two account at a time with same phone no then delete one account..
I tried below Trigger but there problem is if i am inserting one account with existing account phone no then it is working fine but on the insertion of two account it's not working...
can someone please help me...
trigger DelOneAcc on Account (before insert) {  
    // Here i am storing phone of account into set
    Set <String> phoneSet = new Set<String>();      
    // Iterate through each Account and add their phone number to their respective Sets   
    for (Account Acc:trigger.new) {        
    // New list to store the found phone numbers  
    List <Account> AccList = new List<Account>();      
    AccList = [Select Id, Name, Phone from account WHERE phone IN :phoneSet];     
    // Iterating through each account record to see if the same phone was found     
    for (Account Acc:AccList) {        
        If (AccList.size() > 1) {                             
    delete AccList; 
Thank You in Advance
I am beginner in Salesforce.
In other languages, I can debug easily, like in PHP , I can echo any variable, then I can understand, what is happening. 
In Salesforce class, I have many queries which contains some variable also. I wanted to system.debug the queries, but only first one is printing, other system.debug is not printing. Why it is happening?

And how to  efficiently, can debug in Salesforce?

Thank you guys.
@isTest private class TestAccountDeletion { @isTest static void TestDeleteAccountWithOneOpportunity() { // Test data setup // Create one account with one opportunity by calling a utility method Account[] accts = TestDataFactory.createAccountsWithOpps(1,1); // Perform test Test.startTest(); Database.DeleteResult result = Database.delete(accts[0], false); Test.stopTest(); // Verify that the deletion should have been stopped by the trigger, // so check that we got back an error. System.assert(!result.isSuccess()); System.assert(result.getErrors().size() > 0); System.assertEquals('Cannot delete account with related opportunities.', result.getErrors()[0].getMessage()); } }
 1.when i am trying in developer console its showing TestDataFactory variable does not exit
 Conference Management App - Create a Lightning Component with Server-Side Apex Controller:

Step 5: Add Component to the Speaker Record Page
Click App Default and then Assign as App Default.
Select the Conference app, then click Next and then Save.
Question: Does anyone know why Conference Management App is not listed for selection?

User-added image
I am also getting this error when I verify the hands on challenge:Note all APEX codes saved without errors. and all other steps worked.
Step not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject

Thanks in advance for your help.
Challenge Not yet complete... here's what's wrong: 
The runWarehouseEquipmentSync method does not appear to have run successfully. Could not find a successfully completed @future job for this method. Make sure that you run this method at least one before attempting this challenge. Since this method is annotated with the @future method, you may want to wait for a few seconds to ensure that it has processed successfully.

here is my code

public with sharing class WarehouseCalloutService {
    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    // complete this method to make the callout (using @future) to the
    // REST endpoint and update equipment on hand.
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        String ret = '';
        if (response.getStatusCode() == 200) {
            // Deserialize the JSON string into collections of primitive data types.
            List<Object> results = (List<Object>) JSON.deserializeUntyped(response.getBody());
            List<Product2> LstProduct = new List<Product2>();
            for(Object obj : results)
                Map<String, Object> mapobj = (Map<String, Object>)obj;
                Product2 product = new Product2();
                Integer maintenanceperiod = (Integer)mapobj.get('maintenanceperiod');               
                Integer Lifespan = (Integer)mapobj.get('lifespan');
                Integer Cost = (Integer)mapobj.get('cost');
                Boolean replacement = (Boolean)mapobj.get('replacement');
                Integer quantity = ((Integer)mapobj.get('qIntegerntity'));
                product.Name  = (String)mapobj.get('name'); 
                product.Maintenance_Cycle__c = Integer.valueof(maintenanceperiod);
                product.Cost__c = Cost;
                product.Current_Inventory__c = quantity;
                product.Lifespan_Months__c = Lifespan; 
                product.Replacement_Part__c = replacement;
                product.Warehouse_SKU__c = (String) mapobj.get('sku');
                product.ProductCode = (String)mapobj.get('_id');       
             upsert LstProduct Warehouse_SKU__c;
Hello, I need help
I have these 2 custom objects
OT__c has an master relationship with the Pre_Factura__c
And I want to deploy this apex class into the Production but I get the code coverage error
but I don't know how to test this class, can someone help me pls?

public class OTRapidaController {

    public Pre_Factura__c prefactura;
    public OT__c ot;
    public Pre_Factura__c getPreFactura(){
        if(prefactura==null)prefactura=new Pre_Factura__c();
        return prefactura;
    public OT__c getOT(){
        if (ot==null)ot=new OT__c();
        return  ot;
    public PageReference save(){
        insert prefactura;
        insert ot;
        PageReference OTRapida = new ApexPages.StandardController(ot).view();
        return OTRapida;

Hi folks,
How to make visualforce page responsive?
Hi All,

I am using a email template, I wanted to put a hyperlink in this template named "Click on this".

When user click on this "Click on this" hyper link. User should it should redirect to the record/detail page.

This is very urgent. Please help.

I am generating a PDF on case insert using trigger. I need to add an image and signature to it. Is it possible?
I am generating pdf like this

String pdfContents = '<html>';
pdfContents += UserInfo.getUserName();
pdfContents += '<div>';
pdfContents += '</body>';
pdfContents += '</html>';

Blob pdfBlob = Blob.toPDF(pdfContents);
Trying to deploy development from my sandbox using change sets. Whilst custom fields, tabs etc come across fine, the triggers are failing with the following error:

Code Coverage Failure Your organization's code coverage is 0%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

This means nothing to me and I'm just getting more confused looking through the help documents. I don't really do code and I don't know where to start. Any help would be very much appreciated
How can i ignore the www. for not showing an error example (www.yahoo.com = yahoo.com; www.cs.org != www.cs.ph)
here is duplication method for my website. Thanks in advance

public static void checkDuplicateWebsite(List<Account> newRecord){
       for(Account a: newRecord){
           List<Account> account = [SELECT Id, Website FROM Account WHERE Website=:a.Website];
               a.adderror('You cannot create a duplicate Website');

I'm trying to copy a new user as contact by using a trigger but I'm getting the following error


MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User


trigger Acceleration_User_Copyto_Contact on User (after insert, after update) {
   // Map<String,User> newLead = new Map <String, User>();
    system.debug('Acceleration_User_Copyto_Contact Trigger....');
    for ( User user : System.Trigger.new)
        if  (user.Email.contains('acceleration'))
            system.debug('Acceleration_User_Copyto_Contact Trigger..2.');
            Integer RecordCount = [select count() from Contact c where c.Email = : user.Email];
            system.debug('Acceleration_User_Copyto_Contact Trigger..2a .' + RecordCount);
            if (RecordCount == 0)
                String AccountId = '';
                for ( Account a : [Select a.Id From Account a where Name = 'Acceleration']) 
                    system.debug('Acceleration_User_Copyto_Contact Trigger..3.');
                    AccountId = a.Id;
                    Contact con = New Contact();
                    con.AccountId = AccountId ;
                    con.Email = user.Email;
                    con.Firstname = User.Firstname;
                    con.Lastname = User.Lastname ;
                    con.User__c = User.Id;
                    insert con;