• Dave The Rave
  • NEWBIE
  • 50 Points
  • Member since 2015
  • Salesforce Adminstrator

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 35
    Replies
All, having difficulty solving this issue,

I would like to create a formula for a Day/Time field called ProcessDate__c. I would like to take the date from the date/time field registrationdate__c and just amend the time.

Using a formula recommended through the forum, but still can solve issue as this formula adds one day.

DATETIMEVALUE( TEXT( DATEVALUE( RegistrationDate_c ) ) +" "+ "23:59:00" ) - 0.041

if registrationdate__c = 01/01/2019 10:00 then processdate__c should be:
01/12/2019 23:59 not 02/12/2019 23:59

Thanks Dave

oh, 0.041 is for the GMT+1 timezone.
 
Reposted - Date/Time field Formula help
 
I have an existing date/time field
 
RegistrationDate_c = example value 31/12/2019 14:34
 
I would like to create a new date/time formula field based on the date from RegistrationDate__c, so need a formula here.
 
New field is ProcessDate__c
 
ProcessDate__c = the date from RegistrationDate__c and time must be always 23:59
 
So if RegistrationDate__c = 01/12/2019 15:45 then ProcessDate should be 01/12/2019 23:59
 
Can anyone help? I have searched documentation online but cannot find the syntax for the formula.
 
Yes, you guessed this field will be used to trigger a process.
 
Regards Dave
I would like to create a new date/time field based on a foirmula:

RegistrationDate (for example) = 01/01/2019 13:45

(new field) Process Date = Registration Date + time = 11:59, so example:

Process Date = 01/01/2019 11:59

Thanks Dave
Orders are not stored in SF, there is a link to an external website with the order number is required to view orders.

How can I create a formula field to show a clickable URL and use data from field OrderID__c as part of the URL. So see below [ORDER ID] needs to be replaced by OrderID__c (text field) from SF object Orders_c. The new field I am creating is called LinkToOrder__c

https://admin.it.testwebsite.com/adminpanel/index.php?controller=AdminOrders&id_order=[ORDER ID]&vieworder.

Can anyone help? thanks Dave

 
Process Builder - add contact to specific campaign
 
Our customers will log into our website (managed by 3rd party) and register for an event. 3rd party sends API to update a picklist (multiple select) field on the contact record. The contact needs to be added to a specific campaign based on the value most recently change/added to the contact record.
 
Field is EventName_c
 
Values: EventA, EventB, EventC
 
If the value is EventA then the contact needs to be added to Campaign = Event A
If the value is EventB then the contact needs to be added to Campaign = Event B etc.
 
After several months the field EventName_c will have several values, depending on how many events a contact registers for.
 
I can see how to add a contact to a campaign, but not a way to choose the campaign based on the value of a specific field on the contact object.
 
Any ideas?
 
In the same process flow, I then need to send the contact a template email, but again based on the specific event they have chosen.
 
Dave, (and no we are not looking to purchase marketing automation software)
I understand that you cannot add fields to the recycle bin page for a specific tab. 

I would like to retrieve deleted records from the CASE object which have a specific recordtype. 

I tried to do this in the Developer Console with SOQL but this still does not work.

I read that you need to de an SOQL All Query, I am an administrator.
Can somebody help me out here? 

Thanks,

Dave
Hi All,

I wrote a formula that works for a formula field, but I need to replace TODAY() with DateMeeting__c:

1) This works:

((((YEAR(Contact__r.FirstCertRegFromDate__c))=YEAR(TODAY())) && (Contact__r.FreePointsRequired__c=Contact__r.FreePointsObtainedYear1__c)))

2) This is the amended version, but has a syntax error:

((((YEAR(Contact__r.FirstCertRegFromDate__c))=YEAR(DateMeeting__c)) && (Contact__r.FreePointsRequired__c=Contact__r.FreePointsObtainedYear1__c)))

Can anyone help me correct the 2nd formula? is there not also a tool to help SF Admins correct formulas? maybe with difference colours for each bracket set?

Thanks,

Dave
I have created 2 separate process in the process builder on the same object. I learnt now this is not best practice as you cannot control which process is triggered first.

Other than manually, is there a quick way to merge the processes together?

Thanks, Dave
Hi All,

I having created an SOQL which should show records where the value of two number fields is NOT EQUAL to each other.
 
SELECT Id, name, ContactPerson__c, CertRegOrganisation2__c, CertRegStatus__c, obligatoryPointsReq__c, ObligatoryPointsObtainedYr1__c  
FROM Registration_Layer__c
WHERE CertRegOrganisation2__c = 'SCVM' AND CertRegStatus__c = 'Valid' AND obligatoryPointsReq__c <> ObligatoryPointsObtainedYr1__c

The two fields in question are obligatoryPointsReq__c <> ObligatoryPointsObtainedYr1__c, what is the correct syntax for this?

Thanks,

David
All,

I am trying to write an SOQL query to return all filenames from files which are uploaded via a specific custom object.

With the code below I managed to return the file name I wanted, but the files will eventually have lots of different names. The files are uploaded via my FreeMeeting__c object.
 
SELECT Id, ContentDocument.Title, ContentDocument.createdDate, 
FROM ContentDocument
WHERE ContentDocument.Title LIKE 'Superman%'

 
Hi all,

The code below involve 2 objects Registration_Layer__c & Meeting__c. It is a master-detail relationship. Each contact has a upto 3 records on the Registration_Layer__c, when you create a record on Meeting__c and populate fields datemeeting__c and points__c, the fields obligatorypointsobtainedYR1,YR2 etc should be populate with the value of points__c according to the year in datemeeting__c.

However, I get an error when trying to save a new record on the meeting__c object.

"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger TrgOnMeeting caused an unexpected exception, contact your administrator: TrgOnMeeting: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TrgOnMeeting: line 20, column 1"

What did I do wrong? 

​Thanks, Dave
 
Trigger TrgOnMeeting on Meeting__c (After insert, After Update){
     Set<Id> regIds = new Set<Id>();
	
	if(Trigger.isInsert || Trigger.isUpdate) {
        for(Meeting__c meeting : Trigger.new) {
            if(meeting.Registration_Layer__c != null)
                regIds.add(meeting.Registration_Layer__c);
        }
       }  
        Map<Id, Registration_Layer__c> mapReg = new Map<Id, Registration_Layer__c>([SELECT Id, CertRegFrom__c, ObligatoryPointsObtainedYr1__c, ObligatoryPointsObtainedYr2__c, ObligatoryPointsObtainedYr3__c, 

ObligatoryPointsObtainedYr4__c, ObligatoryPointsObtainedYr5__c, ObligatoryPointsObtainedYr6__c
                                                                                  FROM Registration_Layer__c WHERE Id IN: regIds]);
         
        for(Meeting__c meeting : Trigger.new) {
             
            if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year()))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr1__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 1))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr2__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 2))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr3__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 3))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr4__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 4))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr5__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 5))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr6__c += meeting.Points__c;
            }
        }
         
        update mapReg.values();
    }

 
Hi All,

The code  below from (Matheus Sales Ferreira) is for 2 Objects: Registration_Layer__c and Meeting__c. It is a master-detail relationship Meeting__c to Registration_Layer__c. The code below produces several errors which appear on different lines of code, but all start with "Variable Does Not Exist" - Registration_Layer__c and then for datemeeting__c, freepoints__c and points__c.

Errors as above on lines which contain the above fields, so lines 6,7,15,16,17.18.19.20.21.22.23.24.25.26.

I think it is eactly the same issue for each line.
Trigger TrgOnMeeting on Meeting__c (before insert, before Update){
    if(Trigger.isInsert || Trigger.isUpdate) {
        Set<Id> regIds = new Set<Id>();
         
        for(Account meeting : Trigger.new) {
            if(meeting.Registration_Layer__c != null)
                regIds.add(meeting.Registration_Layer__c);
        }
         
        Map<Id, Registration_Layer__c> mapReg = new Map<Id, Registration_Layer__c>([SELECT Id, CertRegFrom__c, ObligatoryPointsObtainedYr1__c, ObligatoryPointsObtainedYr2__c, ObligatoryPointsObtainedYr3__c, ObligatoryPointsObtainedYr4__c, ObligatoryPointsObtainedYr5__c, ObligatoryPointsObtainedYr6__c
                                                                                  FROM Registration_Layer__c WHERE Id IN: regIds]);
         
        for(Account meeting : Trigger.new) {
             
            if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year()) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr1__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 1) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr2__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 2) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr3__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 3) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr4__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 4) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr5__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 5) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr6__c += meeting.Points__c;
            }
        }
         
        update mapReg.values();
    }
}


 
"Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'."

Help, has anyone every got the above error?  Someone very kindly from this forum provided me with the code, I cut and paste it in to the developer console and got this error. Naturally, I have asked this person about this error, but everyone is welcome to comment on this issue.

Dave
After a record is created, I would like to update several number fields based the the date value on fields from 2 different objects. I tried this in the process builder but it did not work.

Attached is an image with object & field names, the list is also at the end of this message. In the Schema Builder the Master-Detail relationship is Meeting__c to RegistrationLayer__c and a Lookup Relationship Meeting__c to RegistrationLayer__c.

After a record on the Meeting__c object is created a process needs to be initiated to update the value of PointsYR1__c, PointsYR2 etc.. (on the RegistrationLayer__c  object) with Points__c (on the Meeting__c object). The YEAR on the two date fields of the two objects much match in order for PointsYR1__c etc.. to be updated.

The logic should be:

IF YEAR(datemeeting__c) = YEAR(certregfrom__c) AND freepoints__c =TRUE THEN  PointsYR1__c = (PointsYR1__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +1 ) AND freepoints__c =TRUE THEN  PointsYR2__c = (PointsYR2__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +2 )  AND freepoints__c =TRUETHEN  PointsYR3__c = (PointsYR3__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +3)  AND freepoints__c =TRUETHEN  PointsYR4__c = (PointsYR4__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +4) AND freepoints__c =TRUE THEN  PointsYR5__c = (PointsYR5__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +5) AND freepoints__c =TRUE THEN  PointsYR6__c = (PointsYR6__c + Points__c)


Fieldname Field Type
Meeting__c (Object)
Points__c 
datemeeting__c 
freepoints__c

Registration__c (object)
CertRegFrom__c
 PointsYR1__c
 PointsYR2__c
 PointsYR3__c
 PointsYR4__c
 PointsYR5__c
 PointsYR6__c



 
I have two fields RegFrom__c and RegUntil__c.

I would like to calculate how many calendar years there are between 2 dates WHERE:

CertRegFrom__c= 01-06-2018
CertRegUntil__c = 02-06-2023

This is a period of 5 years, but 6 calendar years, so result of the formula should be 6, the formula below returns 5. 

between the dates above you have the following calendar years 2018, 2019, 2020, 2021, 2022, 2023.

If CertRegFrom = 01-01-2018 AND CertRegUntil = 31-01-2022 then the formula must equal = 5
 
(CertRegUntil__c - CertRegFrom__c) /365

Can anyone help me adapt this formula?

Dave
All,

Currently In the blue diamond in the process builder, I have the formula with the first 4 lines below, this works perfectly. However, I would like to add the last 2 lines below to my formula. There are 3 criteria A,B,C ( 2 rows below per criteria)

 IF  formula A AND (B OR C) = TRUE (criteria is met), the question is where do I add the AND and OR statements and where do I put the extra brackets? Can any one help by adding AND and OR statement and brackets in Red text, so I can improve my knowledge?
 
A
 
[Registration_Layer__c].CertRegOrganisation2__c ="SCVM" &&[Registration_Layer__c].ActivityStatus2__c  = "active" &&
[Registration_Layer__c].ObligatoryPointsReq__c = 9 &&
 
 
 
B
 
MONTH([Registration_Layer__c].CertRegFrom__c) >= 5 && MONTH([Registration_Layer__c].CertRegFrom__c) <= 8 &&
YEAR([Registration_Layer__c].CertRegFrom__c) = YEAR(TODAY())
 
 
 
C
 
MONTH([Registration_Layer__c].CertRegUntil__c) >= 5 && MONTH([Registration_Layer__c].CertRegUntil__c) <= 8 &&
YEAR([Registration_Layer__c].CertRegUntil__c) = YEAR(TODAY())
 
 

Below the formula are all together: (3 rows per letter A, B, C)
 
[Registration_Layer__c].CertRegOrganisation2__c ="SCVM" &&
[Registration_Layer__c].ActivityStatus2__c  = "active" && [Registration_Layer__c].ObligatoryPointsReq__c = 9 &&
 
MONTH([Registration_Layer__c].CertRegFrom__c) >= 5 && MONTH([Registration_Layer__c].CertRegFrom__c) <= 8 &&
YEAR([Registration_Layer__c].CertRegFrom__c) = YEAR(TODAY())
 
MONTH([Registration_Layer__c].CertRegUntil__c) >= 5 && MONTH([Registration_Layer__c].CertRegUntil__c) <= 8 &&
YEAR([Registration_Layer__c].CertRegUntil__c) = YEAR(TODAY())

 
I created a very complex process in the process builder in our sandbox (Partial Copy), then I did something really stupid, I refreshed the sandbox with the production environment.

Help!
Hi All,

I am trying to update 1 custom field of existing records using the dataloader, I get this error in the dataloader

"Attempt to de-reference a null object"

How can I solve this?

In my CSV file there are only 2 columns of data, contact ID and FakeTriggerField. There are definately comma separating each column of data.

Thanks,

Dave
I created a new (boolean) field "FakeFieldTrigger__c" on the contact object, defaut value = FALSE, I would like to change the value to TRUE, but get an error.

List<Contact> recList = [SELECT Id, FakeFieldTrigger__c FROM Contact WHERE FakeFieldTrigger__c = FALSE;  ];
for (Contact rec : recList) {
rec.FakeFieldTrigger__c = TRUE;
}
update recList;


Error:

Line: 1, Column: 5
Unexpected token '<'.

Can you help me update the value of this boolean field, I can then trigger my process in the process builder.

Thanks,

Dave
I have created a report to show all Salesforce reports which have been run by my users in 2018.

I would like summarize the report by the field "LastRun" and either put the LastRun field into a bucket field, either months "January, February etc..) or pull the month value out of the field "LastRun" and create a new field called "LastRunMonth". However, it seems I cannot create a custom field as Report is not an object.

From searching through Google, I see it is not possible to put date fields into a bucket. So then the only option is to create a new field, but how?

Any ideas on how to do this?

Thanks Dave
Reposted - Date/Time field Formula help
 
I have an existing date/time field
 
RegistrationDate_c = example value 31/12/2019 14:34
 
I would like to create a new date/time formula field based on the date from RegistrationDate__c, so need a formula here.
 
New field is ProcessDate__c
 
ProcessDate__c = the date from RegistrationDate__c and time must be always 23:59
 
So if RegistrationDate__c = 01/12/2019 15:45 then ProcessDate should be 01/12/2019 23:59
 
Can anyone help? I have searched documentation online but cannot find the syntax for the formula.
 
Yes, you guessed this field will be used to trigger a process.
 
Regards Dave
I would like to create a new date/time field based on a foirmula:

RegistrationDate (for example) = 01/01/2019 13:45

(new field) Process Date = Registration Date + time = 11:59, so example:

Process Date = 01/01/2019 11:59

Thanks Dave
Process Builder - add contact to specific campaign
 
Our customers will log into our website (managed by 3rd party) and register for an event. 3rd party sends API to update a picklist (multiple select) field on the contact record. The contact needs to be added to a specific campaign based on the value most recently change/added to the contact record.
 
Field is EventName_c
 
Values: EventA, EventB, EventC
 
If the value is EventA then the contact needs to be added to Campaign = Event A
If the value is EventB then the contact needs to be added to Campaign = Event B etc.
 
After several months the field EventName_c will have several values, depending on how many events a contact registers for.
 
I can see how to add a contact to a campaign, but not a way to choose the campaign based on the value of a specific field on the contact object.
 
Any ideas?
 
In the same process flow, I then need to send the contact a template email, but again based on the specific event they have chosen.
 
Dave, (and no we are not looking to purchase marketing automation software)

Hi all, 

I have a question regarding the DATETIMEVALUE function. I'm creating a task each time a projects starts, and i would like to set the reminder at 09:30:00. So the date is based on a field, but the time should be fixed. I have tried multiple formulas, currently i have the following: 


DATETIMEVALUE(Customfield__c  & " " & 09:30:00) 

However, i receive an error that i miss a bracket: 

The formula expression is invalid: Syntax error. Missing ')'

Anyone any ideas? 

Kind regards, Loran

 

I understand that you cannot add fields to the recycle bin page for a specific tab. 

I would like to retrieve deleted records from the CASE object which have a specific recordtype. 

I tried to do this in the Developer Console with SOQL but this still does not work.

I read that you need to de an SOQL All Query, I am an administrator.
Can somebody help me out here? 

Thanks,

Dave
Hi all,

The code below involve 2 objects Registration_Layer__c & Meeting__c. It is a master-detail relationship. Each contact has a upto 3 records on the Registration_Layer__c, when you create a record on Meeting__c and populate fields datemeeting__c and points__c, the fields obligatorypointsobtainedYR1,YR2 etc should be populate with the value of points__c according to the year in datemeeting__c.

However, I get an error when trying to save a new record on the meeting__c object.

"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger TrgOnMeeting caused an unexpected exception, contact your administrator: TrgOnMeeting: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TrgOnMeeting: line 20, column 1"

What did I do wrong? 

​Thanks, Dave
 
Trigger TrgOnMeeting on Meeting__c (After insert, After Update){
     Set<Id> regIds = new Set<Id>();
	
	if(Trigger.isInsert || Trigger.isUpdate) {
        for(Meeting__c meeting : Trigger.new) {
            if(meeting.Registration_Layer__c != null)
                regIds.add(meeting.Registration_Layer__c);
        }
       }  
        Map<Id, Registration_Layer__c> mapReg = new Map<Id, Registration_Layer__c>([SELECT Id, CertRegFrom__c, ObligatoryPointsObtainedYr1__c, ObligatoryPointsObtainedYr2__c, ObligatoryPointsObtainedYr3__c, 

ObligatoryPointsObtainedYr4__c, ObligatoryPointsObtainedYr5__c, ObligatoryPointsObtainedYr6__c
                                                                                  FROM Registration_Layer__c WHERE Id IN: regIds]);
         
        for(Meeting__c meeting : Trigger.new) {
             
            if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year()))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr1__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 1))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr2__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 2))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr3__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 3))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr4__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 4))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr5__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 5))  {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr6__c += meeting.Points__c;
            }
        }
         
        update mapReg.values();
    }

 
Hi All,

The code  below from (Matheus Sales Ferreira) is for 2 Objects: Registration_Layer__c and Meeting__c. It is a master-detail relationship Meeting__c to Registration_Layer__c. The code below produces several errors which appear on different lines of code, but all start with "Variable Does Not Exist" - Registration_Layer__c and then for datemeeting__c, freepoints__c and points__c.

Errors as above on lines which contain the above fields, so lines 6,7,15,16,17.18.19.20.21.22.23.24.25.26.

I think it is eactly the same issue for each line.
Trigger TrgOnMeeting on Meeting__c (before insert, before Update){
    if(Trigger.isInsert || Trigger.isUpdate) {
        Set<Id> regIds = new Set<Id>();
         
        for(Account meeting : Trigger.new) {
            if(meeting.Registration_Layer__c != null)
                regIds.add(meeting.Registration_Layer__c);
        }
         
        Map<Id, Registration_Layer__c> mapReg = new Map<Id, Registration_Layer__c>([SELECT Id, CertRegFrom__c, ObligatoryPointsObtainedYr1__c, ObligatoryPointsObtainedYr2__c, ObligatoryPointsObtainedYr3__c, ObligatoryPointsObtainedYr4__c, ObligatoryPointsObtainedYr5__c, ObligatoryPointsObtainedYr6__c
                                                                                  FROM Registration_Layer__c WHERE Id IN: regIds]);
         
        for(Account meeting : Trigger.new) {
             
            if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year()) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr1__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 1) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr2__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 2) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr3__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 3) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr4__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 4) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr5__c += meeting.Points__c;
            } else if(meeting.datemeeting__c.Year() == (mapReg.get(meeting.Registration_Layer__c).CertRegFrom__c.Year() + 5) && meeting.freepoints__c) {
                mapReg.get(meeting.Registration_Layer__c).ObligatoryPointsObtainedYr6__c += meeting.Points__c;
            }
        }
         
        update mapReg.values();
    }
}


 
"Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'."

Help, has anyone every got the above error?  Someone very kindly from this forum provided me with the code, I cut and paste it in to the developer console and got this error. Naturally, I have asked this person about this error, but everyone is welcome to comment on this issue.

Dave
After a record is created, I would like to update several number fields based the the date value on fields from 2 different objects. I tried this in the process builder but it did not work.

Attached is an image with object & field names, the list is also at the end of this message. In the Schema Builder the Master-Detail relationship is Meeting__c to RegistrationLayer__c and a Lookup Relationship Meeting__c to RegistrationLayer__c.

After a record on the Meeting__c object is created a process needs to be initiated to update the value of PointsYR1__c, PointsYR2 etc.. (on the RegistrationLayer__c  object) with Points__c (on the Meeting__c object). The YEAR on the two date fields of the two objects much match in order for PointsYR1__c etc.. to be updated.

The logic should be:

IF YEAR(datemeeting__c) = YEAR(certregfrom__c) AND freepoints__c =TRUE THEN  PointsYR1__c = (PointsYR1__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +1 ) AND freepoints__c =TRUE THEN  PointsYR2__c = (PointsYR2__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +2 )  AND freepoints__c =TRUETHEN  PointsYR3__c = (PointsYR3__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +3)  AND freepoints__c =TRUETHEN  PointsYR4__c = (PointsYR4__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +4) AND freepoints__c =TRUE THEN  PointsYR5__c = (PointsYR5__c + Points__c)
IF YEAR(datemeeting__c) = YEAR(certregfrom__c +5) AND freepoints__c =TRUE THEN  PointsYR6__c = (PointsYR6__c + Points__c)


Fieldname Field Type
Meeting__c (Object)
Points__c 
datemeeting__c 
freepoints__c

Registration__c (object)
CertRegFrom__c
 PointsYR1__c
 PointsYR2__c
 PointsYR3__c
 PointsYR4__c
 PointsYR5__c
 PointsYR6__c



 
I have two fields RegFrom__c and RegUntil__c.

I would like to calculate how many calendar years there are between 2 dates WHERE:

CertRegFrom__c= 01-06-2018
CertRegUntil__c = 02-06-2023

This is a period of 5 years, but 6 calendar years, so result of the formula should be 6, the formula below returns 5. 

between the dates above you have the following calendar years 2018, 2019, 2020, 2021, 2022, 2023.

If CertRegFrom = 01-01-2018 AND CertRegUntil = 31-01-2022 then the formula must equal = 5
 
(CertRegUntil__c - CertRegFrom__c) /365

Can anyone help me adapt this formula?

Dave
I created a very complex process in the process builder in our sandbox (Partial Copy), then I did something really stupid, I refreshed the sandbox with the production environment.

Help!