• Puneeth Kumar
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 16
    Replies
Hello all,

I have been struggling with the above error I get when trying to insert Opportunitylineitems in the test class. Although I am passing the same values for the pricebookid and pricebookentry I am getting the above error. Could anyone please assist if they have any known solution. Thanks in advance.

 Code as below:

@istest
public class TestOpportunityLineItemTriggerHandlerV2 {
    static testmethod void testInsert(){
    
        test.startTest();
        
        Country__c c=new Country__c();
        c.Name='United States';
        c.Active__c=true;
        insert c;
        
        State__c s=new State__C();
        s.name='Texas';
        s.Country__c= c.id;
        insert s;
        
        AccountTAHelper.isAccountTriggerCall = false;
        Account a = new Account();
        a.name = 'test';
        a.City__c='Plano';
        a.Phone='235-345-4564';
        a.Zip_Postal_Code__c='75025';
        a.Siebel_Row_Id__c='1-AX4BC4';
        a.country__c=c.id;
        a.state__c=s.id;
        insert a; 
        
        Contact con = new Contact();
        con.firstName = 'test';
        con.lastName = 'test';
        con.accountId = a.Id;
        insert con;
        
        
        id pricebookId = Test.getStandardPricebookId();
        
        Product2 p2 = new Product2();
        p2.name = 'test';
        p2.Family = 'License';
        p2.IsActive =true;
        insert p2;
        
        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, Product2Id = p2.Id, UnitPrice = 10000, IsActive = true);
        insert standardPrice;
        
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = p2.Id, UnitPrice = 12000, IsActive = true);
        insert customPrice;
        
        Opportunity o = new Opportunity();
        o.name = 'test';
        o.stageName = '07 - Closed Won';
        o.accountId = a.Id;
       // system.debug('Inside create oppt Pid is as:'+ pid);
        o.Pricebook2id=customPB.Id;
        o.closeDate = system.today().adddays(30);
        o.LeadSource = 'Deal Registration';
        o.Dell_Referral_Opty_ID__c='345hxrff';
        insert o;   
        
        OpportunityContactRole ocr = new OpportunityContactRole();
        ocr.opportunityId = o.Id;
        ocr.contactId = con.Id;
        insert ocr;
        
        
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.opportunityId = o.id;
        oli.PricebookentryId = customPrice.Id;
        oli.TotalPrice = 500;
        insert oli;
        
        test.stopTest();
    }
    
}

Getting error on the line - " Insert oli; "
 
Hi All,

I have a usecase when record is created, update "Exp Date" of record and set the time based action (Email and field update) on 10 days before "Exp Date". I had achieved this through workflow and time based action.
But On the 10 days before Exp Date that is when time based action is fired I would like to check the criteria as
(If "Stage = prospect" on 10 days before Exp then send mail alert) or (If Stage = "other values" on 10 days before Exp update the fields.)

Workaround What I did:
Created Workflow which updates "Exp Date" field and schedules a time based field update of a "Flag" to true.
Created another process builder while on create and edit where it checks as below
     Node 1 --> ("Flag = true & Stage = prospect) if true then send email alert.  And Update "Flag" to False.
     Node 2 --> ("Flag = true & Stage != prospect) if true then update fields. And Update "Flag" to False.
     Node 3 --> If Flag is True, Update it with False (as I considered this flag acts like a time based update which when updated the record enters process builder to check certain criteria and then do Email alert or field update)

The problem I face is - Will the Time-based Flag update is considered as Triggering point for the process builder to start and check the critria at that specific time ? Are Time-based field updates are considered as enough DML operation to start another Process ??

Let me know if I am doing wrong anywhere or if this is not the way it should be done. Please post your workarounds if any.
Please Advise. 
Hi All,

I have minor issues regards to picklist field. Appriciate if anyone can help me. Below are the issues
  1.  When ever I use change sets to deploy picklist fields I always get confused with the picklist values cause
    •  when I deploy a new picklist field all the values are able to find but when I do deploy an existing picklist field after adding few field values I'm not able to find those edited values after my deployment to next environment. 
    • I assumed that picklist values are not deployed along with field deployment and done manually, but is this the regular behaviour or its just a bug? 
  2.  I had another problem where not able to find the "Picklist Value Set" section for picklist field definition(even though the picklist contains value). As it was not added to any record types assumed the block was not visible but not able to see even after activating the existing values for few record types. How is this possible ?

Is there any considerations for picklist fields for it behaviour (other than assigning them through record type) please advise.

Thanks
 
Hi All,

I have a requirement where given the list of account Ids in CSV file and all related contacts under those accounts need to be extracted in CSV. For this I want to query all the contact with (Select ID,Name from contacts where Account.ID IN: [Read from csv file]) , or simple parsing the list of IDs from csv file to a variable and then querying on that variable. Can anyone help me out in how to achieve this through apex code.

Thank you.
Hi All, 

I found something crazy in opportunity object that is Partner Account field which is standard Lookup(account), I see 2 lookup(account) standard fields in opportunity object. I heard in few other orgs people are not able to find this field on their side. Can anyone explain me about this particular field, Why is it visible for few orgs and what is the related list name on account object. 

Thank you.
Hi All,

I got piece of code in my test class which uses objects belonging to Territory management 2.0, was unable to initialize a variable of type 'UserTerritory2Association' . I see there are diference in objects from TM --> TM 2.0, acoordingly I have changed my code but still the same error persists. For refernece attaching screenshot as well as error. Please advice.

I have the error in line 75
User-added image

Error: sObject type 'UserTerritory2Association' is not supported.
 
Hi All,

I have created an opportunity through SOAPUI which i have associated with Account, Contact. My next step is to associate the opportunity with selected products to it. How can I achieve this in order to link oppty with products and product groups(Which is custom object in org) Any sample Xml call can be helpful. Please advice. 

Thank you.
 
Hi All,

I have constructed a button "Request portal access" which is onclick javascript button on detail page. Associated an apex class where it checks the logic "if contact record has 'Portal access' flag uncheck, then check it and make button disable".  How can I implement in my code for Disable of that button. And also another button "Reject Portal Access" where on clicking it unchecks the flag and button gets disabled. 

While executing the logic either of the buttons should not be disabled or enabled at the same time, cause it is like contradiction. How can I execute this behaviour in my code for the button? 

Please advise 

Thanks
Puneeth
Hi All,

I want to get the the product name(in Product2 object), product group name (in Product_Hierarchy__c) from price book entry on below criteria, I have written this query which is wrong I believe. Can anyone please help me out in querying. Providing relationship btween objects from schema builder.
User-added image

Select Product2.Name,
Product_Hierarchy__c.Name
From PricebookEntry, Product2, Product_Hierarchy__c
Where PricebookEntry.Pricebook2Id = ’ 01s30000000GUqhAAG’ and
PricebookEntry.Product2Id = Product2.Id and Product2.Product_Hierarchy__c = Product_Hierarchy__c.Id

Please advice.
External system(SharePoint) is making SOAP API call to create a record in salesforce, on which creation of records upon meeting a field criteria a workflow should be triggered in updating field values. When a record is created through Salesforce UI the workflow runs fine but when it is getting created through API call seems like workflow is not running. 

So is it something like we cannot invoke Workflow/Aprroval process in sfdc through external API call? If so what thinigs should be done to trigger Workflow/approval process through external SOAP API calls?
Hi
If we have single sfdc instance and 2 divisions, with 2 users each. What the best practice to restrict access to users if we don't want users in either of the division to see the information what's on other side? 

Thank you.
Hello Everyone,

I'm currently having issue in standard list controller module where I'm unable to see list of contacts in the preview section. I've used the code given in module. Even though I have so many contacts in my salesforce org. Can anyone please help me out.Here is the code which I've used. 
Not even able to see single contact. User-added image
External system(SharePoint) is making SOAP API call to create a record in salesforce, on which creation of records upon meeting a field criteria a workflow should be triggered in updating field values. When a record is created through Salesforce UI the workflow runs fine but when it is getting created through API call seems like workflow is not running. 

So is it something like we cannot invoke Workflow/Aprroval process in sfdc through external API call? If so what thinigs should be done to trigger Workflow/approval process through external SOAP API calls?
Hello Everyone,

I'm currently having issue in standard list controller module where I'm unable to see list of contacts in the preview section. I've used the code given in module. Even though I have so many contacts in my salesforce org. Can anyone please help me out.Here is the code which I've used. 
Not even able to see single contact. User-added image
Hello all,

I have been struggling with the above error I get when trying to insert Opportunitylineitems in the test class. Although I am passing the same values for the pricebookid and pricebookentry I am getting the above error. Could anyone please assist if they have any known solution. Thanks in advance.

 Code as below:

@istest
public class TestOpportunityLineItemTriggerHandlerV2 {
    static testmethod void testInsert(){
    
        test.startTest();
        
        Country__c c=new Country__c();
        c.Name='United States';
        c.Active__c=true;
        insert c;
        
        State__c s=new State__C();
        s.name='Texas';
        s.Country__c= c.id;
        insert s;
        
        AccountTAHelper.isAccountTriggerCall = false;
        Account a = new Account();
        a.name = 'test';
        a.City__c='Plano';
        a.Phone='235-345-4564';
        a.Zip_Postal_Code__c='75025';
        a.Siebel_Row_Id__c='1-AX4BC4';
        a.country__c=c.id;
        a.state__c=s.id;
        insert a; 
        
        Contact con = new Contact();
        con.firstName = 'test';
        con.lastName = 'test';
        con.accountId = a.Id;
        insert con;
        
        
        id pricebookId = Test.getStandardPricebookId();
        
        Product2 p2 = new Product2();
        p2.name = 'test';
        p2.Family = 'License';
        p2.IsActive =true;
        insert p2;
        
        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, Product2Id = p2.Id, UnitPrice = 10000, IsActive = true);
        insert standardPrice;
        
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = p2.Id, UnitPrice = 12000, IsActive = true);
        insert customPrice;
        
        Opportunity o = new Opportunity();
        o.name = 'test';
        o.stageName = '07 - Closed Won';
        o.accountId = a.Id;
       // system.debug('Inside create oppt Pid is as:'+ pid);
        o.Pricebook2id=customPB.Id;
        o.closeDate = system.today().adddays(30);
        o.LeadSource = 'Deal Registration';
        o.Dell_Referral_Opty_ID__c='345hxrff';
        insert o;   
        
        OpportunityContactRole ocr = new OpportunityContactRole();
        ocr.opportunityId = o.Id;
        ocr.contactId = con.Id;
        insert ocr;
        
        
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.opportunityId = o.id;
        oli.PricebookentryId = customPrice.Id;
        oli.TotalPrice = 500;
        insert oli;
        
        test.stopTest();
    }
    
}

Getting error on the line - " Insert oli; "
 
Hi All,

I have a requirement where given the list of account Ids in CSV file and all related contacts under those accounts need to be extracted in CSV. For this I want to query all the contact with (Select ID,Name from contacts where Account.ID IN: [Read from csv file]) , or simple parsing the list of IDs from csv file to a variable and then querying on that variable. Can anyone help me out in how to achieve this through apex code.

Thank you.
Hi All, 

I found something crazy in opportunity object that is Partner Account field which is standard Lookup(account), I see 2 lookup(account) standard fields in opportunity object. I heard in few other orgs people are not able to find this field on their side. Can anyone explain me about this particular field, Why is it visible for few orgs and what is the related list name on account object. 

Thank you.
Hi All,

I got piece of code in my test class which uses objects belonging to Territory management 2.0, was unable to initialize a variable of type 'UserTerritory2Association' . I see there are diference in objects from TM --> TM 2.0, acoordingly I have changed my code but still the same error persists. For refernece attaching screenshot as well as error. Please advice.

I have the error in line 75
User-added image

Error: sObject type 'UserTerritory2Association' is not supported.
 
Hi All,

I have constructed a button "Request portal access" which is onclick javascript button on detail page. Associated an apex class where it checks the logic "if contact record has 'Portal access' flag uncheck, then check it and make button disable".  How can I implement in my code for Disable of that button. And also another button "Reject Portal Access" where on clicking it unchecks the flag and button gets disabled. 

While executing the logic either of the buttons should not be disabled or enabled at the same time, cause it is like contradiction. How can I execute this behaviour in my code for the button? 

Please advise 

Thanks
Puneeth
Hi All,

I want to get the the product name(in Product2 object), product group name (in Product_Hierarchy__c) from price book entry on below criteria, I have written this query which is wrong I believe. Can anyone please help me out in querying. Providing relationship btween objects from schema builder.
User-added image

Select Product2.Name,
Product_Hierarchy__c.Name
From PricebookEntry, Product2, Product_Hierarchy__c
Where PricebookEntry.Pricebook2Id = ’ 01s30000000GUqhAAG’ and
PricebookEntry.Product2Id = Product2.Id and Product2.Product_Hierarchy__c = Product_Hierarchy__c.Id

Please advice.
External system(SharePoint) is making SOAP API call to create a record in salesforce, on which creation of records upon meeting a field criteria a workflow should be triggered in updating field values. When a record is created through Salesforce UI the workflow runs fine but when it is getting created through API call seems like workflow is not running. 

So is it something like we cannot invoke Workflow/Aprroval process in sfdc through external API call? If so what thinigs should be done to trigger Workflow/approval process through external SOAP API calls?
Hello Everyone,

I'm currently having issue in standard list controller module where I'm unable to see list of contacts in the preview section. I've used the code given in module. Even though I have so many contacts in my salesforce org. Can anyone please help me out.Here is the code which I've used. 
Not even able to see single contact. User-added image
Hi all,

I'm stuck in the Apex Integration Services - Apex SOAP Callouts challenge with the following message "The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.".

Could you please advise ?