• Alan McQueen
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 2
    Replies
I have a date field on child object . receiveddate__c. I have a field on parent object mostrecentproductreceived__c. Is it possible to use workflow or process builder to update the mostrecentproductreceived__c field on parent based on the receiveddate__c. 

If there are two  child records , Record1 with  receiveddate__c = 11 May 2020 and Record2 with receiveddate__c = 1 May 2020. Then the mostrecentproductreceived__c should have the product from first record. 

if a new child record Record3 is added with receiveddate__c = 13 May 2020 then mostrecentproductreceived__c should be the product from this record. 

If Record1 is updated receiveddate__c = 14 May 2020 then mostrecentproductreceived__c should be the product from this record. 

How can I do this?
 
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?
Hi there,

I have a question about the current capabilities of the platform, specifically whether or not it is still possible to call an Apex Class (REST Controller) WITHOUT any type of authentication token.

I'd like to do something very similar to what is described here: https://sfdcpanther.wordpress.com/2017/10/02/create-anonymous-salesforce-apex-rest-api-with-force-com-platform/comment-page-1/?unapproved=16634&moderation-hash=55f27da1ca3642e19c81c11a00c65de6#comment-16634

Unfortunately, that does not seem to work as I get a 401 Unauthorized with an error code of "INVALID_SESSION_ID" despite my attempts.  

All of the documentation I've read describes an authentication step first, so has there been some change on the SFDC side to require authentication since the blog above was posted 5 years ago (I've been unable to find a specific post that clearly states such a change, but it may be out there)?  Is there another way to accomplish anonymous access besides what was described in that blog?

Thanks in advance!