• v varaprasad
  • PRO
  • 3772 Points
  • Member since 2015
  • Salesforce Developer

  • Chatter
    Feed
  • 121
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 829
    Replies
Hi,

I am starting my salesforce lightning component framework superbadge and I have written the below code. I am using the component in a lightning app and using the preview for testing. Can you please let me know why the dropdown menu and buttons are not aligned properly.

Code

<aura:component >
    <aura:attribute name="attr_selectTypeBoat" type='String[]' default='All Types'/>
    <lightning:layout horizontalAlign="center">
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:select aura:id="selectTypeBoat" name="selectType" label='Please select'>
                    <aura:iteration items='{!v.attr_selectTypeBoat}' var='option'>
                        <option value='{!option}' text='{!option}' />
                    </aura:iteration>
                </lightning:select>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:button label="Search" variant="brand"/>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <lightning:button label="New" variant="neutral"/>
            </lightning:layoutItem>
        </lightning:layout>
</aura:component>

Output

User-added image

Thanks
Vinny
 
HI Guys.

Looking for some help writing  a test class. Very basic, just record creation.

Visualforce page is basic, just standard controller Account.

 
public class AccExtension4 {

private final Account objacc;


    public AccExtension4(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
    
     public Account acc {get; set;}
     public Opportunity opp {get; set;} 
     Account cust = new Account();   
     Opportunity opps = new Opportunity();


public PageReference Save() {


       //Add all the class information then insert the class
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Customer_Row_ID__c = objacc.Customer_Row_ID__c;           
        cust.RecordTypeid = '0120E000000aznK';
        upsert cust Customer_Row_ID__c;
    
    
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
 
 
return new PageReference('/'+ opps.id); 
         
         }

    }


I had a look online for an example to use.
This is what has given me a low code coverage.
@isTest 
public class AccExtension2Test 
{
 static testMethod void testMethod1() 
 {
 Account testAccount = new Account();
        testAccount.LastName= 'test last name';
        testAccount.FirstName= 'test first name';
        testAccount.Phone= '021000000'; 
        testAccount.PersonMobilePhone= '021000000'; 
        testAccount.PersonEmail= 'nihan@gmail.com';          
        testAccount.Siebel_References__c = 'tester' ;           
        testAccount.Siebel_Customer_Row_ID__c = '32pkj-32nm';           
        testAccount.RecordTypeid = '012D00000003KdL';
        upsert testAccount Siebel_Customer_Row_ID__c ;



 Test.StartTest(); 
  ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
  AccExtension4 testAccPlan = new AccExtension4(sc);

  PageReference pageRef = Page.FibreSimplex; // Add your VF page Name here
  pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
  Test.setCurrentPage(pageRef);

  //testAccPlan.save(); call all your function here
 Test.StopTest();
 }
}

 
Hi,
We have a third party app that requires me to expose certain data in Salesforce (person account object) through their API. They already have one built, just need me to expose the correct data. How would I go about doing this? 

Any help is much appreciated!
Many Thanks,
Natasha 

 
Hi,
I have written the apex class for addition of two numbers. but for writing the test class i have issue.
Program is
--------------
public class Add 
{    
public integer a;
public integer b;
public integer c;
public integer addt()
{
    c=a+b; 
    system.debug('the result is'+c);
    return c;
}      
}

My test class
-----------------
@istest
public class Addtest
{
static testmethod void testadd()
{
    Add ad=new Add();
    integer res=ad.addt();
    system.assertEquals(res);
}
}
the test class is throwing error as
"Method does not exist or incorrect signature: void assertEquals(Integer) from the type System"

Any guidance please

Thanks in advance.
Hello folks , 
Requirement:  Can any one tell me how to write a trigger on contact to check the duplicates for Name , phone , email . if any duplicate arises we need to put error message . condition is (Name OR phone OR Email).

trigger DuplicateTwoFieldsContact on Contact (before insert,before update) 
{
 if(trigger.isBefore)
 {
  map<String,Contact> mapcontact = new map<String,Contact>();
   map<String,Contact> phonemap = new map<String,Contact>();
  
  for(contact con: trigger.new) 
   {
   if(                                                 
   ((con.Email != null) && (Trigger.isInsert || con.email != trigger.oldmap.get(con.id).email )) ||
    ((con.Phone != null) && (Trigger.isInsert || con.Phone != trigger.oldmap.get(con.id).Phone ))
    )
     {                                
     if( !mapcontact.containskey(con.Email) || !phonemap.containskey(con.Phone))
      {
      mapcontact.put(con.Email ,con);
      phonemap.put(con.Phone ,con);
      
      } 
     }
   }
 
 for(contact c:[select id ,Email ,Phone from contact where Email =: mapcontact.keyset() OR Phone =: phonemap.keyset() ])
 {
 contact newcontact = mapcontact.get(c.Email);
  newcontact.Email.adderror('Duplicate Email has been detected ');
 
 contact Phonecontact = phonemap.get(c.Phone);
  Phonecontact.Phone.adderror('Duplicate Phone has been detected ');
 
 }
 }
}

Hi,

I would lik to query all validation rules that contain a condition with profiles. Is this possible?

Thanks in advance!

I'm trying to write a class that will call a flow. I don't understand why Dev Console won't let me save, telling me that myFlow.start() is an invalid constructor name.
User-added image
Hi, 

I have a list with the following format in apex controller. 

Custom__Object_Analysis__c:{Id=a0L1N00000L1izqUAB, Name=All Accounts, CreatedDate=2018-02-15 15:15:12, isCustom__c=false, Fields__c=0, Filter__c=Industry = '', Object_Name__c=account, Tally__c=0}

How do I serialize this? 
JSON.Serialize() gives Uncaught SyntaxError: Unexpected string 
Hi,
Test Class Failing for Methods defined as TestMethod do not support getContent call


Test Class:
@isTest
private class PicklistDescriberTest {
 
    @isTest 
    static void test() {
        
        Map<String, Schema.RecordTypeInfo> recordTypes = Schema.SObjectType.Account.getRecordTypeInfosByName();
        List<String> recordTypeNames = new List<String>(recordTypes.keyset());
         
      
        
        Account testAccount = new Account(Name='Test Account', Continent__c = 'Asia', Country__c = 'India', RecordTypeId = recordTypes.get(recordTypeNames[0]).getRecordTypeId());
        insert testAccount;
        
          
        
        System.assert(PicklistDescriber.describe(testAccount.Id, 'Asia').size()!=0);
        
        
        System.assert(PicklistDescriber.describe('Account', recordTypeNames[0], 'Continent__c').size() > 0);
        
        System.assert(PicklistDescriber.describe('Account', recordTypes.get(recordTypeNames[0]).getRecordTypeId(), 'Continent__c').size() > 0);
        
        System.assert(PicklistDescriber.describe('Account', recordTypeNames[0], 'Country__c', 'Continent__c').size() > 0);
        
        System.assert(PicklistDescriber.describeWithDependency('Account', recordTypeNames[0], 'Country__c', 'Continent__c').size() > 0);
        
        System.assert(PicklistDescriber.describeWithDependency('Account', recordTypes.get(recordTypeNames[0]).getRecordTypeId(), 'Country__c', 'Continent__c').size() > 0);
    }
    
}



Actual Class:

public with sharing class PicklistDescriber {
    static final Pattern OPTION_PATTERN = Pattern.compile('<option.+?>(.+?)</option>');

    /**
        Desribe a picklist field for an sobject id. RecordType is automatically picked
        based on the record's RecordTypeId field value.
        example usage :
        List<String> options = PicklistDescriber.describe(accountId, 'Industry');
    */
    public static List<String> describe(Id sobjectId, String pickListFieldAPIName) {
        return parseOptions(
                            new Map<String, String> {
                                                     'id' => sobjectId,
                                                     'pickListFieldName'=> pickListFieldAPIName
                                                    }
                            );
    }

    /**
        Describe a picklist field for a SobjectType, its given record type developer name and the picklist field
        example usage :
        List<String> options = PicklistDescriber.describe('Account', 'Record_Type_1', 'Industry'));
    */
    public static List<String> describe(String sobjectType, String recordTypeName, String pickListFieldAPIName) {
        return parseOptions(
                            new Map<String, String> {
                                                     'sobjectType' => sobjectType,
                                                     'recordTypeName' => recordTypeName,
                                                     'pickListFieldName'=> pickListFieldAPIName
                                                    }
                            );
    }

    /**
        Describe a picklist field for a SobjectType, its given record type ID and the picklist field
        example usage :
        Id recType1Id = [Select Id from RecordType Where SobjectType = 'Account'
                                            AND DeveloperName like 'Record_Type_2'].Id;
        System.assertEquals(REC_TYPE_1_OPTIONS, PicklistDescriber.describe('Account', recType2Id, 'Industry'));
    */
    public static List<String> describe(String sobjectType, Id recordTypeId, String pickListFieldAPIName) {
        return parseOptions(
                            new Map<String, String> {
                                                     'sobjectType' => sobjectType,
                                                     'recordTypeId' => recordTypeId,
                                                     'pickListFieldName'=> pickListFieldAPIName
                                                    }
                            );
    }

    public static List<String> describe(String sobjectType, String recordTypeName, String pickListFieldAPIName, String contrfieldName) {
        return parseOptions(
                            new Map<String, String> {
                                                     'sobjectType' => sobjectType,
                                                     'recordTypeName' => recordTypeName,
                                                     'pickListFieldName'=> pickListFieldAPIName,
                                                     'contrfieldName' => contrfieldName
                                                    }
                            );
    }

    public static Map<String,List<String>> describeWithDependency(String sobjectType, String recordTypeName, String pickListFieldAPIName, String contrfieldName) {
        Map<String, List<String>> result = new Map<String,List<String>>();
        Map<String, List<String>> depentOptions = PicklistFieldController.getDependentOptionsImpl(sobjectType, contrfieldName, pickListFieldAPIName);
        for(String pickval : PicklistDescriber.describe(sobjectType, recordTypeName, pickListFieldAPIName, contrfieldName)) {
            for(String dep : depentOptions.keySet()) {
                result.put(dep, new List<String>());
                for(String val : depentOptions.get(dep)) {
                    if(val == pickval) {
                        result.get(dep).add(val);
                    }
                }
            }
        }

        return result;
    }

    public static Map<String,List<String>> describeWithDependency(String sobjectType, Id recordTypeId, String pickListFieldAPIName, String contrfieldName) {
        Map<String, List<String>> result = new Map<String,List<String>>();
        Map<String, List<String>> depentOptions = PicklistFieldController.getDependentOptionsImpl(sobjectType, contrfieldName, pickListFieldAPIName);
        for(String pickval : PicklistDescriber.describe(sobjectType, recordTypeId, pickListFieldAPIName)) {
            for(String dep : depentOptions.keySet()) {
                result.put(dep, new List<String>());
                for(String val : depentOptions.get(dep)) {
                        System.debug(val);
                        System.debug(pickval);
                    if(val == pickval) {
                        result.get(dep).add(val);
                    }
                }
            }
        }

        return result;
    }

    /*
        Internal method to parse the OPTIONS
    */
    static List<String> parseOptions(Map<String, String> params) {
        PageReference pr = Page.PicklistDesc;
        // to handle development mode, if ON
        pr.getParameters().put('core.apexpages.devmode.url', '1');

        for (String key : params.keySet()) {
            pr.getParameters().put(key, params.get(key));
        }

        String xmlContent = pr.getContent().toString();

        Matcher mchr = OPTION_PATTERN.matcher(xmlContent);
        List<String> options = new List<String>();
        while(mchr.find()) {
            System.debug(mchr.group(1));
            options.add(mchr.group(1));
        }
        // remove the --None-- element
        if (!options.isEmpty()) options.remove(0);
        return options;
    }
}
Hi,

I have created a simple Rest API endpoint however my test class is not touching the endpoint at all. The API URL mapping is

//** services/apexrest/accounts/0016E00000YNC49/entitlements
@RestResource(urlMapping='/accounts/*/entitlements')
Global with sharing class U4_REST_AccountEntitlements {
    @HttpGet
    global static Account getAccount(){

and returns entitlement values. Using REST Explorer within workbench it works perfectly but when I run the test class it is not returning any values. In fact ... the result is [REST_AccountEntitlements_TEST].RestResource response:RestResponse:[headers={}, responseBody=null, statusCode=null]​

Any help would be much appreciated.
Test.startTest();

           Id recordId = NewServiceAccount.Id;
           RestRequest request = new RestRequest();
           RestResponse response = new RestResponse();
           request.httpMethod = 'GET';

           Request.requestURI  ='/services/apexrest/accounts/'+NewServiceAccount.Id+'/entitlements';
           System.debug(LoggingLevel.Info,'+*+*+*+*+*+*+* '+NewServiceAccount.id);

           System.debug(LoggingLevel.Info,'[REST_AccountEntitlements_TEST].RestResource response:'+Request.requestURI);

           RestContext.request = request;
           RestContext.response = response;

           System.debug(LoggingLevel.Info,'[REST_AccountEntitlements_TEST].RestResource response:'+response); 
  
        Test.stopTest();

 
I have tried this :
trigger Surajtrg on Contact (after insert, after update, after delete)
{
    set<id> act=new set<id>();
    List <Account> lstAccountsToUpdate = new List <Account>();
    if(trigger.isInsert ||trigger.isUpdate)
    {
        for(contact cc:trigger.new)
        {
            act.add(cc.AccountId);
         }
    }
    if(trigger.isDelete)
    {
        for(contact cc:trigger.old)
        {
            act.add(cc.AccountId);
        }
    }
    List<Account> shocksList = [SELECT Id,Youngest__c,(SELECT id,MIN(Age__c) FROM Contact) from Account where Id IN: act]; 
for(Account acc:shocksList) //(Select Id from Contacts)  represents size of Contacts        
{
    Account accObj = new Account ();
    accObj.Id = acc.Id;
   accObj.Youngest__c= acc.MIN(Age__c);
    lstAccountsToUpdate.add(accObj);
}
    Update lstAccountsToUpdate; 
}
 
I have multiple contacts with their different ages. I want to fetch out minimum and max age among all contacts. 
I tried this query....Select id,Min(age__c) from Contact GROUP BY Name.
please correct me
Hi everyone, 

I'm a new developer so please bear that in mind! I'm trying to update an Account's custom fields from a Custom Object called Pub_Opportunity__c. The account has a lookup relationship to the pub_opportunity__c. But I only want the Account to update once with these fields as sometimes there are many pub opportunities related to one Account. I just want to retain the original values. 

When I use the code below, it keeps updating the Account every single time with the new Pub Opportunity's fields regardless of the condition. For example, when I change the Account_Status__c field on the Account to 'Active', when I create a new Pub Opportunity, it still updates the Account_Status__c to 'Closed Won - Implementing'. Even when the Link_to_Contract__c field on the Account is filled out, it still updates the field with the new value from the Pub Opportunity. 

Would appreciate your help!


public static void updatePubs(Map<Id,Pub_Opportunity__c> pubOppMap){
        List<Account> aList = new List<Account>();
        
        for(Pub_Opportunity__c p : pubOppMap.values()){
            Account a = new Account();
            if(a.Account_Status__c != 'Active'){
                a.Account_Status__c = 'Closed Won - Implementing';
                a.id = p.Publisher__c;
               if(String.Isblank(a.Link_to_Contract__c)){
                a.Link_To_Contract__c = p.Link_to_Contract__c;
            }
          
            aList.add(a);
        }
        
        if(aList.size() > 0){
            update alist;
        }
    }
    }
    
I am trying to search through all records passed in by trigger and find ones where buyer zip codes matches an open Open Territory. The "Name" field on Open_Territory__c contains zip codes.

I am getting 2 errors. Variable does not exist: Name, and DML requires SObject or SObject list type: List<Id>.

Any help would be appreciated. 
 
public static void setOpenTerritory(List<dealer__Sales_Up__c> triggerValues) {
        List<Open_Territory__c> openList = [SELECT Id, Name FROM Open_Territory__c WHERE Is_Active__c = true];
        List<Id> suToUpdate = new List<Id>();
        System.debug('openList contains ' + openList);
        // Search through all Sales Ups passed in trigger. Find ones with buyer zip codes matches Open Territory zip and add them to List.
        for(dealer__Sales_Up__c s : triggerValues) { 
            if(s.dealer__Mailing_Zip__c === openList.Name){
                s.Open_Territory__c = true;
                suToUpdate.add(s.Id);
            }
        }
        update suToUpdate;
    }

 
Hi 

require help in class 

global class CDPForecastExtractBatch implements Database.Batchable<sObject> {
    
    String query;
    Forecast_Scenario__c forecastScenario;
    
    global CDPForecastExtractBatch(Forecast_Scenario__c scenario) {
        forecastScenario = scenario;
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        query = 'SELECT Id, Deal__c, Deal__r.Parent_Deal_Id__c, Deal__r.Stage__c, Deal__r.IsPlaceholder_Deal__c, Deal__r.IsInfrastructure_Deal__c, Deal__r.RecordType.Name, Deal__r.Is_Cloned_Deal__c, Deal__r.Is_Closed_Deal__c, Deal__r.Forecast_Scenario__c, ';
        query += '(SELECT Id, CDP_Asset__c, Customer__c, Customer__r.Name,Customer__r.Account_Subtype__c FROM CDP_Asset_Customer_Accounts__r) , ';
        query += '(SELECT Id, Development_Deal_Id__c, Land_Name__c, CDP_Asset__c, Land_Area__c, Land_Area_UOM__c, Land_Source__c, Land_Code__c FROM CDP_Land_Strategy__r) '; 
        query += 'FROM CDP_Asset__c WHERE (NOT Deal__r.Stage__c like \'%Lost%\')  AND (Deal__r.Is_Cloned_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
        query += 'AND Deal__r.Hold__c = false AND (Deal__r.IsNamedDeal__c = true OR Deal__r.IsPlaceholder_Deal__c = true OR Deal__r.IsInfrastructure_Deal__c = true OR (Deal__r.Stage__c like \'%Won%\') ) ';
           query += 'AND Deal__r.RecordType.Name NOT IN ('+ '\'Value-Add\'' +')';
        return Database.getQueryLocator(query);
    }

       global void execute(Database.BatchableContext BC, List<sObject> scope) {
        CDPForecastExtractHandler.getChildRecords(scope, forecastScenario);
    }
    
    global void finish(Database.BatchableContext BC) {
        
    }
    
}
On the Case object we have the standard lookup field to the standard Account object. I also added a field called "Login_ID__c". We have this same field (Login_ID__c) in the Account object as well. Now when the user enters a Login ID in the case object, based on the value in the Login ID field it should auto populate the Account lookup field because each Account record has a unique Login ID. I have tried using a workflow and process builder but to no avail. From what I’ve researched, I think it’s possible to do this with an apex trigger but I am not familiar with apex at all. Can anybody help me out or offer any insight? Thank you.
 
WHAT: In my Account object when a field "GDPR flag" gets checked,it should automatically fill the "GDPR date" field to be te same date(date on which the flag chcekbox  gets checked).
So we are using the formula field: IF( R2_ACC_CHK_GDPR_UnSub__c , TODAY() , NULL).
ISSUE: Because of this formula field, the "GDPR date"is getting changed everyday to the current day, which is wrong.It should reflect the day when the checkbox was checked and should stay always the same date.i.e if we marked any customer as GDPR on 09th Sept 2018, tomorrow or one year from now , the date should always reflect 09th sept 2018.
How can i achieve that? Can i make some changes in formula field?or can i do it in the triger code?Please help.I am novice so would require your explanation as well.
 
Hello friends, Iam getting error "Variable does not exist: RecursiveTriggerHandler" while deploying the apex trigger to production.
Please find the trigger below

trigger BD_AccountTrigger on Account (after insert, after update) {
  BD_ProcessSwitchSettings__c custSettings = BD_ProcessSwitchSettings__c.getInstance();
 
 System.debug('****************in BD_LeadTrigger');
 
 if(trigger.isInsert || trigger.isUpdate){
   System.debug('****************in BD_LeadTrigger, Trigger.old:'+trigger.old);
   System.debug('****************in BD_LeadTrigger, Trigger.new:'+trigger.new);
 } 
  
 // if(!custSettings.BD_AllTriggersDisabled__c && custSettings.BD_NotesTriggerEnabled__c){
  if(!custSettings.BD_AllTriggersDisabled__c ){
     if(RecursiveTriggerHandler.isFirstTime){
        RecursiveTriggerHandler.isFirstTime = false;
        new  AC_AccountTriggerHandler().run();
     } 
        
  }
}
I tried to import an Apex trigger and Class I created so that when an opportunity is created a quote is created, with the opportunity's product if it has one. We said me that we have to have 75%code coverage to import it. So I have to create an Apex test. But above my trigger and my class, it is already written 100%, so I don't understand.

Also, my Apex test is only 62%... And I don't know how to increase it. 

/// TRIGGER

trigger Facturation on Opportunity (after insert) {

        List<Id> oppIds = new List<Id>();

        for (Opportunity o : Trigger.new)
            oppIds.add(o.id);

        CreateQuote.createQuote(oppIds);   

}

/// CLASS

public class CreateQuote {

    @future

    public static void createQuote(List<Id> oppIds) {
        List<Quote> lstQ = new List<Quote>();

        //Fetching all the OLIs belonging to the Opportunities of Trigger.new
        List<OpportunityLineItem> olis =[select id, OpportunityId, quantity, PriceBookEntry.Product2Id, UnitPrice, PricebookentryId from OpportunityLineItem where OpportunityId in :oppIds];
        List<Opportunity> opps =[select id, name, CloseDate, Type, Pricebook2Id from Opportunity where Id in :oppIds];

        //Preparing a Map of each Opportunity and their corrresponding LineItems  ( Id of the opportunity => List of the OLIs that belong to the opportunity)
        Map<Id,List<OpportunityLineItem>> mapOppIdOli = new Map<Id,List<OpportunityLineItem>>();
        for (OpportunityLineItem oli : olis) {
            if (mapOppIdOli.containsKey(oli.OpportunityId)) {
                mapOppIdOli.get(oli.OpportunityId).add(oli);
            } else {
                List<OpportunityLineItem> lstOlis = new List<OpportunityLineItem>();
                lstOlis.add(oli);
                mapOppIdOli.put(oli.OpportunityId, lstOlis);
            }
        }

        //Preparing the new quotes - one for each Opportunity
        //List<Opportunity> opps =[select id, name, CloseDate, Pricebook2Id from Opportunity where Id in :oppIds];
        for (Opportunity o : opps) {
            if (o.Type == 'Event') {
                Quote q = new Quote();
                //q.name = 'Credit Note ' + o.name;
                q.name = o.name;
                //q.Montant_1_re_ch_ance__c = 1000;
                q.Date_de_Facture__c = o.CloseDate;
                q.Date_1_re_ch_ance__c = o.CloseDate;
                q.opportunityId = o.id;
                q.Pricebook2Id= o.Pricebook2Id;
                lstQ.add(q);
            }  
        }

        //Inserting the new quotes
        insert lstQ;

        //Preparing the new QLIs - one for each OLI
        List<QuoteLineItem> lstQLI = new List<QuoteLineItem>();
        for (Quote q : lstQ) {
            List<OpportunityLineItem> lstOlis = mapOppIdOli.get(q.OpportunityId);
            if (lstOlis != null) {
                for (OpportunityLineItem oli : lstOlis) {
                    QuoteLineItem qli = new QuoteLineItem();
                    qli.quoteId = q.Id;
                    qli.UnitPrice = oli.UnitPrice;
                    qli.Product2Id = oli.PriceBookEntry.Product2Id;
                    qli.Quantity = oli.Quantity;
                    qli.PriceBookentryid = oli.PriceBookentryId;
                    lstQLI.add(qli);
                }
            }
        }
        //Inserting the new QLIs
        insert lstQLI;
    }
}

/// TEST


@isTest

public class CreateQuoteTest {
    static testMethod void insertNewOpportunity() {
        Test.startTest();

        Product2 testProduct = new Product2(
            Name = 'Happy Funtime Ball'

        );

        insert testProduct;

        PricebookEntry pbEntry = new PricebookEntry(
             Pricebook2Id = Test.getStandardPricebookId(),
             Product2Id = testProduct.Id,
             UnitPrice = 100.00,
             IsActive = true

        );

        insert pbEntry;

        Opportunity testOpportunity = new Opportunity(
            Name = 'Test Opportunity Triggers',
            CloseDate = date.today().addDays(5),        
            StageName = 'Sourcing Demand',
            Type = 'Event',           
            Account_manager_gescom__c = 'Farida Raji',
            Pricebook2Id = pbEntry.Pricebook2Id                      

        );

        insert testOpportunity;

        OpportunityLineItem testOLI = new OpportunityLineItem(
            OpportunityId = testOpportunity.Id,
            Product2Id = testProduct.Id,
            PricebookEntryId = pbEntry.Id,
            Quantity = 5,
            TotalPrice = 5 * pbEntry.UnitPrice        
            //UnitPrice = 1100.00

        );

        insert testOLI;     
        
        OpportunityLineItem testOLI2 = new OpportunityLineItem(
            OpportunityId = testOpportunity.Id,
            Product2Id = testProduct.Id,
            PricebookEntryId = pbEntry.Id,
            Quantity = 5,
            TotalPrice = 5 * pbEntry.UnitPrice         
            //UnitPrice = 1100.00

        );

        insert testOLI2;  
        
        
        Test.stopTest();

    }

}
 
Hi All,

Please help me on below issue.


1. Trigger will work on user mode or system mode
2. In below class account is having one contact but one user able to see contact another user not why another user not able to see contact please help me.

3. As per my knowledge below class will work on system mode.
4. Please help me why another user not ble to see the contact.
 
trigger sampleTrigger on account(after update){
  AccountHelper.Createcontact(Trigger.new);
}

If account type == hot then i need create one conatct for account only one contact.
If contact is existing then no need to crete contact.

public class AccountHelper{

 public static void Createcontact(list<account> accs){
  set<id> acciDs = new set<id>(); 
  for(account acc : accs){
   if(acc.type == 'hot'){    
      acciDs.add(acc.id);   
   } 
 }
 list<account> accslist = [select id,name,(select id from contacts) from acount];
 
 for(account acc : accslist){
     if(acc.contacts.size()== 0){
	 
	    //crating contact here 
	 }
 
 }
}

 
If anybody aware on deleting territories  can help me  because we could not able to delete territories  even though we had "Managed Territories"  permission in profile level. The  territory  trying to delete don't have child  territory but have parent territory.So while deleting I am getting the following error  below.

Error:  
Cannot Delete the Territory
You cannot delete the territory because at least one territory rolls up to it. 

could you please help on this.
I'm looking for a side gig, about 30 hours a week.

My certficiations: http://certification.salesforce.com/certification-detail-print?conId=003G000002FKbh3IAD

I have about 5 years experience with Salesforce. Please send an email: varaprasad4sfdc@gmail.com email for a resume.

Thanks
Varaprasad
@For Support : varaprasad4sfdc@gmail.com
Some users having issue with list views .
Ex : 

DETAILED DESCRIPTION:
1) select a personalized view (here e.g. 003 - My cases in process).
2) open a case out of this list (here e.g. CAS001).
3) go back to the case list by pressing the "Back-Arrow" of the browser .
 
The wrong list of cases is displayed Here.

Any help really appreciated.

Thanks
Varaprasad
Hi ,

Some times in chatter Chatter bold ,italic buttons are not displaying.
User-added image

Please let me know the reason .

Thanks
Varaprasad
 
Hi I have come across the below error, using JavaScript in Button.

An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. 
If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support.
 Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information.
 We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 1652772134-27944 (-1092651723)
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = "{!Opportunity.Opportunity_Product_Count__c}";
var oppid = "{!Opportunity.Id}";
 

if(r == 1 )
{        
                    window.location.href='/apex/VFPageName?id='+oppid;
}
else
{
    alert ("No Products exists !");

Please help me out with alternative solution ASAP
Hi All,

i need to create one validation rule..

User-added image

in each prefernce picklist field i have 3 values
primary
ok to contact
do not contact

Among all 6 fields i need to select only one field value is primary....


Any Help really Appreciate...

Thanks
varaprasad


 
I have a Parent Object called "Treatement" and a child object "Infusion". For a particular treatement we have to create infusion records. the 1st Infusion record should have infusion number (a field in Infusion) as 1 and 2nd record should have infusion number as 2 , and the count should continue. 

How to achive this..

Thanks 
Hi Everyone.

  i need small help regarding on schedule apex.
  how we will schedule one class with different timings.
EX:i want to schedule one class :  Runs at 4:20; 7:50: 16:20; 20:50 CET these timings.

Thanks in Advance


 
Hi All ,

   i am writing test class for following schedule class 
      global class scheduleAccountWriteXML implements Schedulable{
    
    // Execute method
    
    global void execute(SchedulableContext SC) {
        
        try{
      
// Code to be executed when the schedule class wakes up

            
            CalloutAccountRequest.basicAuthCalloutRequest();
           
            String CRON_EXP = '0 0 * * * ?';
            string jobName = 'Account_Interface_Schedule_job_that_runs_every_1_hour_for_Accounts'; 
            scheduleAccountWriteXML p = new scheduleAccountWriteXML();
            system.schedule(jobName, CRON_EXP, p);              
            
        }     
        
        Catch (Exception e){            
            
            Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
           
            emailMessage.setToAddresses(new String[] { 'varaprasad.vemula@accenture.com'});
            emailMessage.setSubject('Subject');
            
          
            emailMessage.setPlainTextBody(e.getmessage());
         
            Messaging.SendEmailResult[] emailResult = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage}, true);
        }
    }
}

I received code 90%,but test execution will be fail .

@isTest
public class Test_scheduleAccountWriteXML {
    public static testmethod void testaccountxml(){
    Test.StartTest();
              
            String CRON_EXP = '0 0 * * * ?';           
            scheduleAccountWriteXML scc6= new scheduleAccountWriteXML();       
            String jobid = system.schedule('varam', CRON_EXP, scc6);  
        
     Test.StopTest();  
        
         
    }
}


Any help please.


 
Hi Everyone ,

i created one class for generating xml file and by using callouts i am sending file to external system.
Here my requirement is 
  EX : file is more than one mb 1.5 mb
          i need to split xml file one is 1MB
                                          2nd one is 0.5mb
                                           is it possible to split file,,,,  Give me some ideas

Thanks all.
 
Hi

    I need to create multiple tasks in single page and i need to assign to user.Through vf page how we will implement this one .

 We need to have a VF section  so that from same page I can create multiple tasks without navigating to different page. Essentially in new task we need to have all the fields and can only refer what is in Action plan. 

Thanks to all ....
 

 
Hi All

   A and B are objects having lookup relationship
   A is parent and having status field
   B is child having status field
here my requiremeent is parent is having n on of childs in child what is the staus field value i need to update same thing in parent....

Thanks to alll
 
Hi I have come across the below error, using JavaScript in Button.

An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. 
If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support.
 Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information.
 We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 1652772134-27944 (-1092651723)
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = "{!Opportunity.Opportunity_Product_Count__c}";
var oppid = "{!Opportunity.Id}";
 

if(r == 1 )
{        
                    window.location.href='/apex/VFPageName?id='+oppid;
}
else
{
    alert ("No Products exists !");

Please help me out with alternative solution ASAP
Hi All,

i need to create one validation rule..

User-added image

in each prefernce picklist field i have 3 values
primary
ok to contact
do not contact

Among all 6 fields i need to select only one field value is primary....


Any Help really Appreciate...

Thanks
varaprasad


 
Hi, 

I am trying to execute Apex test (run synchronous) using rest explorer in workbench. But, the response is null. Please help me.

User-added image

Thanks and Regards,
Diwakar G
Hello,

When somone gives a swagger, What else do we need to do to do testing in Postman.

is there any authentcation key i should ask ?

I imported the swagger and i directly clicked on send
I get below error
{
    "code": "500",
    "name": "Internal Gateway Error",
    "message": "error unknown
}
 
public class SendAccountUsingRESTAPI {
  private final String clientId = 'XXXX';
   private final String clientSecret = 'XXXX';
   private final String username = 'XXXX';
   private final String password = 'XXXX';
  public class deserializeResponse
   {
      public String id;
      public String access_token;
   }
  public String ReturnAccessToken (SendAccountUsingRESTAPI acount)
   {
      String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
     Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setBody(reqbody);
      req.setMethod('POST');
      req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token');
      HttpResponse res = h.send(req);
     deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
     system.debug('@@@@access_token@@ = '+resp1 );
      return resp1.access_token;
   }
}

In this class I am trying to get the access token with the help of ReturnAccessToken() method. But due to some reason it is returning null. I am not getting the access token. All the details I get is Status code = 400 and Status = Bad request. Can anyboody please give a solution to this problem, because I've got stuck here for a long time.
I'm hoping someone can help.  We have a vendor that wrote this code for us (see below). I'm trying to run an Informatica task that updates some users records and this is the error I'm getting.  

Error loading into target [Contact] : Error received from salesforce.com.  Fields [].  Status code [CANNOT_MODIFY_MANAGED_OBJECT].  Message [addToCList: execution of AfterUpdatecaused by: System.QueryException: List has more than 1 row for assignment to SObject()].

I am updating 14 contact records but keep getting a failure and this message is what it's telling me.  But I don't understand what the problem is that is causing this message.  Hopefully someone can help me understand what is happening here.  I'm not a developer but I do understand what is written in the code, I just don't know why it's giving me this partiuclar error.  TIA for any assistance.  



Apex Code
trigger addToCList on Contact (after update) {
for (Contact cont : Trigger.New)
{

if (cont.Jenzabar_ID__c !=null)
{
if (cont.TargetX_SRMb__Student_Type__c=='First-Time Freshman'||cont.TargetX_SRMb__Student_Type__c=='International Freshman')
{
if (cont.TargetX_SRMb__Status__c=='Deposit Paid')
{
addAllAttachments.getAttachmentsForStudent(cont.X18_digit_ID__c,cont.Jenzabar_ID__c);
}
} else 
{
if (cont.TargetX_SRMb__Status__c=='Accept')
{
addAllAttachments.getAttachmentsForStudent(cont.X18_digit_ID__c,cont.Jenzabar_ID__c);

 

Hi All,

I've written a third party integration as a connected app.   This works great with our Developer instance and I can log in with my Salesforce ID and the API calls into my Salesforce data all work great.
But this falls down when trying to make this work with another Salesforce instance outside of our Developer instance.  When trying to sign in to a Salesforce ID on another instance to make this connection, the user gets "OAuth Error 1800 : There was a problem in setting up your remote access.".  I've viewed the few forum posts on this and could not find an applicable solution.

This is a simple API Integration only, NOT an app that gets installed to use from within the Salesforce app.     What permissions or other piece could I be missing?    Please help and thank you.

Write a trigger that creates two identical Opportunities when ever an Account is created.Make sure both opportunities are associates with the Account.
Use any values for the fields on the opportunities
Just make sure to use variables when populating the fields of each opportunity to make sure they are identical.
 
Hey guys,

I have a few active workflows that look at an opportunity, if there's been no activity for 21 days, it'll send a follow up email to the Contact who owns the opportunity. In order have the email sent I have to login as another user, make a minor change on the opportunity to trigger it (usually I'll have a checkbox and do a list view so it's quick), and then the email will send from him. The problem is that everyday because there's hundreds of opportunities I have to go in there and trigger all of these opportunities as him in order for the emails to be sent. Is it possible to create a workflow/process/flow (preferrably not apex) that will automatically check each opportunities "Trigger box" as him, so then the emails automatically send as him without me ever having to go in, login as him, and manually check each opportunities "Trigger box" in a list view???

Thanks!!!
Hello everyone,
I'm a new to salesforce, and couldn't believe the possibility and the support from the salesforce community, I'm glad to join, and looking forward on creating something awsome here. 

I was searching around on how to create different questionnaire (one with yes or no answer, and the other one to score 1-3), and at the end I want to calculate and populate the result and flag it for (red label for example) if the score is greater than certain amount.

Can I make this possible with cutome object.

Hey all :)

Looking for CPQ experts here, we are hitting this error while running the test method, inserting a Quote Line Item:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SBQQ.QuoteLineAfter: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a800j0000008fOtAAI; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Line : Cant update the subscription type on an amendment.: [] 

Any ideas?

Much appreciated in advance,

Regards,
Manuel Reina



 

Hi and thanks for any help or direction.

1. Please tell me if this is good Apex class.  By good I mean, up to SF best practices, bulkification etc.
2. I need help in writing a test class.  

@RestResource(urlMapping='/TmwCaseUpdates/v1/*')

global class TmwCaseUpdates 
{

    global class OrderResponse 
    {
        string OrderNumber;
        List<string> Comments = new List<string>();
        List<string> Errors = new List<string>();
        string CaseNumber;
    }
    
  global class FuelOrderItem
    {
        string FuelOrderNumber;
        string FuelType;
        string CaseNumber;
        long FuelOrderedAmount;
        long FuelDeliveredAmount;
    }
    
  global class SalesforceUpdateCase
    {
        string Status;
        string FuelOrderStatus;
        string TMWOrderNumber;
        DateTime DeliveredTime;
        DateTime CarrierConfirmDateTime;
        string[] CaseComments;
        List<FuelOrderItem> FuelOrderItems;
        string NotifiedDate;
        string CreditAlertType;
        Date RequestDeliveryDate;
        string RequestDeliveryTimeframe;
        string Description;
        string Subject;
        string CompanyCode;
        string Origin;
    long QuantityDelivered;
    long QuantityRequested;
    }
    
    global static string GetAccountID(string companyId)
    {
        string cmpID = 'TMW-' + companyId;
        string accountID = [SELECT IntegratedSite__c FROM Translation_Table__c where Surrogate_ID__c='TMW-JMJHOR01' LIMIT 1].Id;
        return accountID;
    }
    
    @HttpPost
    global static List<OrderResponse> UpdateOrders()
    {
        string requestBody = RestContext.request.requestBody.tostring();
        System.debug('input data is ' + requestBody);
        List<SalesforceUpdateCase> updOrders = (List<SalesforceUpdateCase>)JSON.deserialize(requestBody, List<SalesforceUpdateCase>.class);
        System.debug(updOrders);
        // create OrderResponse list to be returned to the caller
        List<OrderResponse> orderList = new List<OrderResponse>();
        // loop through SalesforceUpdateCase objects.  Create new cases for valid orders.  Return any case comments
        for (SalesforceUpdateCase theOrder : updOrders)        
        {
            OrderResponse theResponse = new OrderResponse();
            List<Case> theCases = new List<Case>();
            theCases =   [ select id, status, AccountId, TMW_Order_Num__c, CaseNumber, Fuel_Order_Status__c 
                         FROM case WHERE TMW_Order_Num__c = :theOrder.TMWOrderNumber ];
            System.debug('order # is ' + theOrder.TMWOrderNumber);
            if (theCases.size() > 1)
            {
                theResponse.Errors.Add('Case ' + theCases[0].CaseNumber + 'for TMW Order ' + theOrder.TMWOrderNumber + ' already exists');
                System.debug('Case ' + theCases[0].CaseNumber + 'for TMW Order ' + theOrder.TMWOrderNumber + ' already exists');
                theResponse.OrderNumber = theOrder.TMWOrderNumber;
                theResponse.CaseNumber = theCases[0].CaseNumber;
                orderList.Add(theResponse);
            } else if (theCases.size() == 0)
            {
                // Create new SF case
                Case newCase = new Case();
        newCase.Status = theOrder.Status;
        newCase.Fuel_Order_Status__c = theOrder.FuelOrderStatus;
        newCase.TMW_Order_Num__c = theOrder.TMWOrderNumber;
        newCase.TMWSentDt__c = Date.today();
        newCase.Credit_Alert_Type__c = theOrder.CreditAlerttype;
                newCase.Delivered_Time__c = theOrder.DeliveredTime;
                // Get the company code from the translation table. Company codes are stored as TMW-xxxxx
                string translatedCompanyCode = 'TMW-' + theOrder.CompanyCode;
                System.debug(translatedCompanyCode);
                newCase.AccountId = [SELECT IntegratedSite__c 
                                     FROM Translation_Table__c 
                                     WHERE Surrogate_ID__c = :translatedCompanyCode].IntegratedSite__c;
                newCase.RQ_Delivery_Timeframe__c = theOrder.RequestDeliveryTimeframe;
                newCase.RQ_Delivery_Date__c = theOrder.RequestDeliveryDate;
                newCase.Origin = theOrder.Origin;
                integer i = 0;
                for (FuelOrderItem item : theOrder.FuelOrderItems)
                {
                    i++;
                    switch on i
                    {
                        when 1 
                        {
                            newCase.Fuel1_Requested_Type__c = item.FuelType;
                            if (theOrder.FuelOrderStatus == 'Delivered')
              {
                newCase.Fuel1_Delivered_Type__c = item.FuelType;
                                newCase.Fuel1_Delivered_Amount__c = item.FuelDeliveredAmount;
                        }
                        }
                        when 2 
                        {
                            newCase.Fuel2_Requested_Type__c = item.FuelType;
                            if (theOrder.FuelOrderStatus == 'Delivered')
              {
                newCase.Fuel2_Delivered_Type__c = item.FuelType;
                                newCase.Fuel2_Delivered_Amount__c = item.FuelDeliveredAmount;
                        }                            
                        }
                        when 3 
                        {
                            newCase.Fuel3_Requested_Type__c = item.FuelType;
                            if (theOrder.FuelOrderStatus == 'Delivered')
              {
                newCase.Fuel3_Delivered_Type__c = item.FuelType;
                                newCase.Fuel3_Delivered_Amount__c = item.FuelDeliveredAmount;
                        }                                            
                        }
                        when 4 
                        {
                            newCase.Fuel4_Requested_Type__c = item.FuelType;
              if (theOrder.FuelOrderStatus == 'Delivered')
              {
                newCase.Fuel4_Delivered_Type__c = item.FuelType;
                                newCase.Fuel4_Delivered_Amount__c = item.FuelDeliveredAmount;
                        }                
                        }
                    }
                }
                System.debug('about to insert case');
        Insert newCase;
        theResponse.OrderNumber = theOrder.TMWOrderNumber;
        theResponse.CaseNumber = newCase.CaseNumber;
        orderList.Add(theResponse);
            }
      else
            {
                // Update existing case
                Case updCase = theCases[0];
                if (updCase.Fuel_Order_Status__c != theOrder.FuelOrderStatus)
                {
                    updCase.Status = theOrder.Status;
                    updCase.Fuel_Order_Status__c = theOrder.FuelOrderStatus;
                    updCase.TMW_Order_Num__c = theOrder.TMWOrderNumber;
                    updCase.TMWSentDt__c = Date.today();
                    updCase.Credit_Alert_Type__c = theOrder.CreditAlerttype;
                    // update Delivered fields for completed orders
                    if (theOrder.FuelOrderStatus == 'Delivered')
                    {
                        for (FuelOrderItem item : theOrder.FuelOrderItems)
            {
                            if (updCase.Fuel1_Requested_Type__c == item.FuelType)
                            { 
                                updCase.Fuel1_Delivered_Amount__c = item.FuelDeliveredAmount; 
                            }
                            else if (updCase.Fuel2_Requested_Type__c == item.FuelType)
                            { 
                                updCase.Fuel2_Delivered_Amount__c = item.FuelDeliveredAmount; 
                            }
                            else if (updCase.Fuel3_Requested_Type__c == item.FuelType)
                            { 
                                updCase.Fuel3_Delivered_Amount__c = item.FuelDeliveredAmount; 
                            }
                            else if (updCase.Fuel4_Requested_Type__c == item.FuelType)
                            { 
                                updCase.Fuel4_Delivered_Amount__c = item.FuelDeliveredAmount; 
                            }
            }
                        updCase.Delivered_Time__c = theOrder.DeliveredTime;
                        updCase.Carrier_Confirm_Date_Time__c = theOrder.CarrierConfirmDateTime;
                    }
                    System.debug('about to update case');
            Update updCase;
                    theResponse.OrderNumber = theOrder.TMWOrderNumber;
                    theResponse.CaseNumber = updCase.CaseNumber;
                    orderList.Add(theResponse);
                }
            }            
        }
        return orderList;
    }
}
 
I am looking to override the Delete button and link on both the contact and lead objects.  Can anyone help me with the Visualforce page and controller class?  
Hello everyone, I am writing a utility class for a trigger. I'm trying to execute a SOQL query that pulls all opportunities, then filters them out by start date and by specific types of classifications. So, the objects that I'm using are: opportunities, contacts, and a custom object called classification type contacts. 

I need to filter out the opportunities by specific classification type contacts. 

The relationships are as follows: 
  • opportunities has a lookup field called "donors" that relates it to contacts
  • contacts has a master-detail relationship with "classification_type_contacts__c"
So far, my SOQL query looks as follows:
 
String classNames = getAggregateDataUtils.getClassNames('Majors'); //utility method to return string of names to filter by
Date startDate = Date.newInstance(2018, 11, 27);
Date endDate = Date.newInstance(2018, 11, 28);
List<Opportunity> opps = [SELECT opp.id, opp.CloseDate, opp.amount, (SELECT Classification_Name__c FROM Classification_Type_Contact__c) FROM Opportunity opp
                          WHERE (opp.CloseDate >=: startDate and opp.CloseDate <=: endDate)
                          AND classification_name__c IN : classNames];
The error I get is as follows:

User-added image


I'm not really sure how to fix this. I think the biggest problem is that there's no lookup field on the Contact to the "Classification_Type_Contact__c", but since there's a Master-Detail relationship, I should still be able to get there, right? I can pull reports with a custom report type that relates the three different objects. 

Thank you in advance for your help!


Best,
Jon
 
Hello Everyone,

I've been trying to do a test Method for a callOut class that invokes a Callout in a future Method, but this is returning System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out only in the test Execution, When running in the normal flow, it responses with no problem.

I've understood that this error is produced when doing a DML statement before a CallOut. However there's no operation besides the createData in the TestSetUp.

I've read some posts and the most likely was this one:  https://developer.salesforce.com/forums?id=906F0000000927CIAQ  .But the proposed solution of Test.StartTest();  Test.SetMock(); ... Test.EndTest()  is already developed.

This is the code returning the error
@isTest
global class RPP_SyncOportunidad_ws_tst {
    
    @testSetup
    static void createData()
    {
        Account acc = new Account();
        acc = new Account();
 		acc.Name='AVX_cuentaPrueba ';
        acc.RPP_NombreComercial__c='NombreComercial '; 
        insert acc;
        
        Contract contrato =  RPP_DataGenerator_cls.crearContrato(true, acc.Id);
        Opportunity objOpp = RPP_DataGenerator_cls.crearOpportunity(false,acc.Id);
        objOpp.RPP_Acuerdo__c= contrato.Id;

        insert objOpp;
    }
    
    public static testMethod void successTest()
    {
        List<Opportunity> lstOpps = [SELECT Id FROM Opportunity];
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockSuccessResponse());
        RPP_SyncOportunidad_ws mci = new RPP_SyncOportunidad_ws(lstOpps);
        Id jobId = System.enqueueJob(mci);
        Test.stopTest();
        
        System.assertNotEquals(mci, null, 'Test error: Cannot create invocacion ws');
    }
    
    global class MockSuccessResponse implements HttpCalloutMock
    {
        global HTTPResponse respond(HTTPRequest req)
        {
            HttpResponse res = new HttpResponse();
            res.setHeader('Content-Type', 'application/json');
            String strJSON ='[\n' +
                '{\n' +
                ' "CodigoError": null, \n' +
                ' "EntidadComercialId": "32201", \n' +
                ' "Estado": "S", \n' +
                ' "Mensaje": "Cliente registrado con éxito", \n' +
                ' "SalesForceGuid": "D58B1521-BAC2-4279" \n' +
                '}\n' +
                ']';                          
            res.setBody(strJSON);
            res.setStatus('OK');
            res.setStatusCode(200);
            return res;
        }
    }
}
It also happens that I have developed other CallOut classes with their own TestClasses and they work just fine.

Has anyone being in this issue?
Is it really necessary for the creation of knowledge articles? How is community user able to create knowledge articles without knowledge user checkbox being checked(I've done that using a lightning component)?
What if I manually gave read, create and edit permissions using a permission set to a user without the knowledge user checkbox being checked, would that user be able to read, create and edit knowledge articles?
Is there a programmatic or declarative approach available to tackle this problem?
Looking for the absolute best way to be a Salesforce Admin. 

I've only been working with Salesforce (mostly uploading info ) at my new job for about a month. I won't be doing much with it but want to become an Admin... I did some research on the topic and feel that I would enjoy a career as an Admin but I need help as we do not have a seasoned Admin. My supervisor has just learned the basics somehow but he is located in Berlin so I can't really learn under him.
Please help.

1)Will trailhead be the best way to study for the exam? is so:
    A) how do I know I am on the right trail on trailhead??

2)Do you recommend paying for classes? if so which ones?
3) any other tips would be helpful.
4) Is there another rout of Salesforce that is better that you enjoy?
Thank you guys!
Hello, 

I'm have an apex class that recieves a variable name and then has to do an query with thin name on Accoun object.
But my variable could use some part of this name only, like when I query the name Liza, I should return every account that has Liza in the middle of it, like Elizabeth.

Can anyone help me?
I'm trying use the operator like, but i dont know how use the syntax for a variable.
 
/**
 * Controller class for C_Header component
 */
public without sharing class C_HeaderCntl {
    @AuraEnabled
    public static String getContactTypeDetail(){
        return C_Utilities.getContactTypeDetail();
    }
}
  • November 26, 2018
  • Like
  • 0
Hi,

I am starting my salesforce lightning component framework superbadge and I have written the below code. I am using the component in a lightning app and using the preview for testing. Can you please let me know why the dropdown menu and buttons are not aligned properly.

Code

<aura:component >
    <aura:attribute name="attr_selectTypeBoat" type='String[]' default='All Types'/>
    <lightning:layout horizontalAlign="center">
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:select aura:id="selectTypeBoat" name="selectType" label='Please select'>
                    <aura:iteration items='{!v.attr_selectTypeBoat}' var='option'>
                        <option value='{!option}' text='{!option}' />
                    </aura:iteration>
                </lightning:select>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:button label="Search" variant="brand"/>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <lightning:button label="New" variant="neutral"/>
            </lightning:layoutItem>
        </lightning:layout>
</aura:component>

Output

User-added image

Thanks
Vinny