• Marco P.
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
Hi all,

I need some help with the following. After the collection of different records across Salesfore, a set of new invoice records is created like the example below

This list is Grouped by Invoice number and Ordered by Header

Example:

Name:                  Header                 Renevue             Invoice number                
Record1               H                             73                           IN2022/500
Record2               X                             100                        IN2022/500
Record3               X                             -23                         IN2022/500
Record4               H                             144                        IN2022/586
Record5               X                             75                           IN2022/586        
Record6               X                             -5                           IN2022/586
Record7               X                             84                           IN2022/586
Record8               X                             -10                         IN2022/586
Record9               H                             180                        IN2022/673
Record10            X                             65                           IN2022/673        
Record11            X                             -3                           IN2022/673
Record12            X                             45                           IN2022/673
Record13            X                             -15                         IN2022/673
Record13            X                             99                           IN2022/673
Record13            X                             -11                         IN2022/673

I’d like to number this list of records afterwards based on this Group and Order. The result should be like this.

Name:                  Header                 Renevue             Invoicenumber                Number
Record1               H                             73                           IN2022/500                        0
Record2               X                             100                        IN2022/500                        1
Record3               X                             -23                         IN2022/500                        2
Record4               H                             144                        IN2022/586                        0
Record5               X                             75                           IN2022/586                         1
Record6               X                             -5                           IN2022/586                        2
Record7               X                             84                           IN2022/586                        3
Record8               X                             -10                         IN2022/586                        4
Record9               H                             180                        IN2022/673                        0
Record10            X                             65                           IN2022/673                         1
Record11            X                             -3                           IN2022/673                        2
Record12            X                             45                           IN2022/673                        3
Record13            X                             -15                         IN2022/673                        4
Record13            X                             99                           IN2022/673                        5
Record13            X                             -11                         IN2022/673                        6

I am really looking forward to anyone’s reaction.
Thanks in advance !


 
Hi,

I'd like to use the User Rolename from the logged in user in a validationrule on an Opportunity but I can't get it to work. I made a formula text field to show $UserRole.Name to see the result but it is empty or not showing. Tried $UserRole.RollupDescription. Also empty or not showing.

UserRole.Name

I quess that is why my validationrule is not working.

I can't find any topic on it but it seems like none of the UserRole fields has any result or it is not showing when I open an Opportunity.

What did I do wrong?

regards,
Marco
Hi,

I'd like to use the User Rolename from the logged in user in a validationrule on an Opportunity but I can't get it to work. I made a formula text field to show $UserRole.Name to see the result but it is empty or not showing. Tried $UserRole.RollupDescription. Also empty or not showing.

UserRole.Name

I quess that is why my validationrule is not working.

I can't find any topic on it but it seems like none of the UserRole fields has any result or it is not showing when I open an Opportunity.

What did I do wrong?

regards,
Marco
Hi,

In my situation I have a Custom Object (Object__c) which can be created in 2 types: TypeA or TypeB, where TypeA is always created first and on a later date TypeB will be created with the same Title and Episode. I created a Trigger that when TypeB is created the Trigger will find a matching TypeA card based on the Title and episode, and fill the new TypeB card with Date1 and Date2 from the matching TypeA card, and it will link TypeA to TypeB with a lookupfield ObjectMatch__c

--------------------------------------------------------
trigger ObjectFindMatch on Object__c (before update) {

  for (Object__c newObj : Trigger.new) {
  for (Object__c extObj : [SELECT Id, Date1__c, Date2__c FROM Object__c 
       WHERE Type__c = 'TypeA' 
       AND Titel_c = :newObj.Titel__c 
       AND Episode_c = :newObj.Episode__c]) { 
  
  IF (newObj.Type__c = 'TypeB') {
      newObj.ObjectMatch__c = extObj.Id;
      newObj.Date1__c = extObj.Date1__c;
      newObj.Date2__c = extObj.Date2__c;
   }

  }
 }
}
--------------------------------------------------------

The Trigger works fine but the cards can also be created in a batch (for example) episodes 1 to 10, then I get a: LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101
I am reading some best practices like:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_bestpract.htm
But I can't figure out how to optimise my code :(

Please help ?

Kind regards,
Marco