• Aliaksei Razumau
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
In my test class I insert new products and pricebookentries, in my test class I don't use seeAllDate=true annotation and in order to retrieve standard pricebook id I used Test.getStandardPricebookId() method, here's my code:
Product2 p1 = new Product2(Name='Product Monthly 1111', Family='Monthly', isActive=true, CurrencyIsoCode='USD');
Product2 p2 = new Product2(Name='Product Yearly 2222', Family='Yearly', isActive=true, CurrencyIsoCode='USD');

insert new List<Product2>{p1, p2};

Id pricebookId = Test.getStandardPricebookId();

PricebookEntry pbe1 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p1.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=100);
PricebookEntry pbe2 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p2.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=50);

insert pbe1;
insert pbe2;

List<PricebookEntry> pbes = [SELECT ID FROM PricebookEntry 
    WHERE Product2id IN (:p1.Id, :p2.Id) AND Pricebook2.isStandard = TRUE AND Pricebook2.isActive = TRUE AND CurrencyIsoCode = 'USD' AND isActive = TRUE];

System.assertEquals(2, pbes.size());


pbes.size() returns 0. I used the same query in console for existing data and I got results. What am I doing wrong?
2 days ago I viewed a queue of Time-Based Workflow rules which notify a specific person (by creating tasks and emailing), but yesterday I found this list is empty. How is that possible that workflow queue was emptied?? I had there more than 200+ items and objects, the rule is tight to (assets), weren't changed.

Yesterday I fixed my rules and using apex triggered WFR to re-evaluate existing records and had my queue populated again... BUT I came in today and it's empty again.

How is it possible? Is it a bug? Or a third party app? How is it possible to track down?
I want to use access codes for specific events. I have a custom object called "Event Codes" with only one primary field which represents access code itself (text symbols only with length < 16, each code is unique). I manually add up new codes to an object. Some contacts and leads have text field with access code and it's one of the values of a custom object mentioned above. I use an integration with 3rd party, so that some contacts and leads have this field populated automatically with access code (text representation).

How can I relate contact / lead with my custom object based on access code? How can I relate already existing records?

I believe "Event codes" object should be a master while lead / contact are children. But I can't create master detail relationship at contact / lead object (have no such option).
I want to add a field to a Campaign which calculates number of CampaignMembers meeting some criteria. In my case, every CampaignMemeber has a checkbox field which shows whether CampaignMember is an existing customer or not. I want to calculate number of customers and display number in Campaign.

How I can do it without writting apex code?

I started creating a field:
1. Chose formula type - I couldn't find CampaignMember object and, as the result, any custom fields, it just doesn't exist. I don't know why? Logically it should be.
2. Chose Roll-up field - I can count number of CampaignMembers but in criteria who'd be included I didn't find any custom CampaignMember fields.

As far as I see now, Campaigns are imature and it differs from other standard objects (e.g. Contacts and Accounts has same relationship). Why?! 
I want to be able to see opportunities related to a specific campaign. But the problem is that all opportunities we create in Sf are related to accounts only and not to contacts. So.. all the data reported in a campaign report is not passed to the report at all. But that's okay, I want to list members of a campaign and list all opportunities related to their accounts.

Relationship seems to be a little bit complicated:

CampaignMembers = Contacts =- Accounts -= Opportunities

where =- many-to-one, = one-to-one and -= one-to-many relationship.

How can I do it?
I want to add a field to a Campaign which calculates number of CampaignMembers meeting some criteria. In my case, every CampaignMemeber has a checkbox field which shows whether CampaignMember is an existing customer or not. I want to calculate number of customers and display number in Campaign.

How I can do it without writting apex code?

I started creating a field:
1. Chose formula type - I couldn't find CampaignMember object and, as the result, any custom fields, it just doesn't exist. I don't know why? Logically it should be.
2. Chose Roll-up field - I can count number of CampaignMembers but in criteria who'd be included I didn't find any custom CampaignMember fields.

As far as I see now, Campaigns are imature and it differs from other standard objects (e.g. Contacts and Accounts has same relationship). Why?! 
In my test class I insert new products and pricebookentries, in my test class I don't use seeAllDate=true annotation and in order to retrieve standard pricebook id I used Test.getStandardPricebookId() method, here's my code:
Product2 p1 = new Product2(Name='Product Monthly 1111', Family='Monthly', isActive=true, CurrencyIsoCode='USD');
Product2 p2 = new Product2(Name='Product Yearly 2222', Family='Yearly', isActive=true, CurrencyIsoCode='USD');

insert new List<Product2>{p1, p2};

Id pricebookId = Test.getStandardPricebookId();

PricebookEntry pbe1 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p1.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=100);
PricebookEntry pbe2 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p2.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=50);

insert pbe1;
insert pbe2;

List<PricebookEntry> pbes = [SELECT ID FROM PricebookEntry 
    WHERE Product2id IN (:p1.Id, :p2.Id) AND Pricebook2.isStandard = TRUE AND Pricebook2.isActive = TRUE AND CurrencyIsoCode = 'USD' AND isActive = TRUE];

System.assertEquals(2, pbes.size());


pbes.size() returns 0. I used the same query in console for existing data and I got results. What am I doing wrong?
I want to add a field to a Campaign which calculates number of CampaignMembers meeting some criteria. In my case, every CampaignMemeber has a checkbox field which shows whether CampaignMember is an existing customer or not. I want to calculate number of customers and display number in Campaign.

How I can do it without writting apex code?

I started creating a field:
1. Chose formula type - I couldn't find CampaignMember object and, as the result, any custom fields, it just doesn't exist. I don't know why? Logically it should be.
2. Chose Roll-up field - I can count number of CampaignMembers but in criteria who'd be included I didn't find any custom CampaignMember fields.

As far as I see now, Campaigns are imature and it differs from other standard objects (e.g. Contacts and Accounts has same relationship). Why?! 
I want to be able to see opportunities related to a specific campaign. But the problem is that all opportunities we create in Sf are related to accounts only and not to contacts. So.. all the data reported in a campaign report is not passed to the report at all. But that's okay, I want to list members of a campaign and list all opportunities related to their accounts.

Relationship seems to be a little bit complicated:

CampaignMembers = Contacts =- Accounts -= Opportunities

where =- many-to-one, = one-to-one and -= one-to-many relationship.

How can I do it?