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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 44
    Replies
add " (speech marks) to a text field using DML statement

I am importing data into SF, but have a comma in some text strings, when you create a CSV the comma is also a delimiter, so I have fields without a header in my CSV file.


Using DML code, I would like to amend several text fields, so:


text__c = I am, a text

" + text__c + " (Concatenate) for example =  "I am, a text"


Thanks,

Dave
The REGEX code below works perfectly, but I now need to allow for the email field also to be blank.

NOT(REGEX(Email ,('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+')))

Can I incorporate NOT ISBLANK( Email ) into the statement above so:

A user can enter an email in the correct format as above or the user does not have to enter an email address at all?

Thanks,

​​​​​​​Dave

 
As a admin, I have created a DML Statement to run in the Developer Console adhoc whenever I need to change account record owners en mass.

Now I need to convert that into an Apex Class and Trigger so that when records are uploaded from an external party the account record owner will be changed automatically based on shippingcity. See DML Code below:
 
List<Account> recList = [select id, shippingcountry, ownerid, name, shippingcity FROM Account WHERE shippingcountry = 'NL' AND sasid__c = null and ownerid='0052o00000AHDCeAAP' AND shippingcity IN ('Nijmegen','Arnhem')];
for (Account rec : recList) {
rec.ownerid = '0052o00000AI4zfAAD';
}
update recList;

3rd Party OwnerID = '0052o00000AHDCeEAP'
New record owner = '0052o00000AI4zfACD'
All,

I have inheritated some code from an old webform which is als web-to-case, however Regex code does not match the vallidation we now require.
 
^(\+4|)?(07[0-8]{1}[0-9]{1}|02[0-9]{2}|03[0-9]{2}){1}?(\s|\.|\-)?([0-9]{3}(\s|\.|\-|)){2}$

The above needs to accept spaces and 0040

e.g. +40 728 318 871

or 0040 728 318 871

Can anyone suggest what the code should be?

Thanks,

​​​​​​​Dave
As a an admin, I am using the Developer Console to execute an SOQL query. The aim is to count the number of records on the lead object where the text fields  "Name = firstname and lastname" and "Company" have the same values.

I wrote this query, but got an error

SELECT Id, firstname, lastname FROM lead WHERE [lastname + firstname = Company]

After searching Google, it seems that the goal is not achievable using SOQL, can anyone confirm this? is there another simple solution using Apex run from the developer console?

For example firstname & lastname = "Peter Smith" AND Company = "Peter Smith",  so this is one record where the name and company are the same.

Thanks,

Dave
I would like to add a column to all existing listviews on the case object. After some searching in Google, I understand that it is possible to amend the metadata of the listview object.

The question is how to do this? 

The addition column is SuuportedVendor__c

Thanks,

Dave
Hi Salesforce developers,

As an admistrator, I need to add one new custom field to all listviews e.g. sharedvendor__c from the case object. There are over 50 different list views.

How can I do this in the most efficient way? I think this might require a DML statement or apex class, but cannot find the answer in any forum.

Can you help?

Dave



 
View automated changes to a record (on a record)
 
When a user makes a change to a record the standard field "Last Modified By" is populated with the user name, time and date. In the Setup Audit Trail you can see exactly what change was made.
 
I would like to see when a System Process makes a change to a field value or creates a record. Let's say you use the process builder to change the value of a field when a user edits a record and certain criteria is met:
 
How can you see that the process builder changed the field value and not the user?
 
The same question is for all automations:
 
Apex Class/Trigger
Workflow
Flow
Process Builder
 
The only idea I can think of is that you create a date/time field and text field, which the automation pre-populates: e.g " Hi I am the Process Builder and changed this record on 10-10-2020 at 14:00, but if you have changes from different automations at the sometime this could be difficult.
 
Thanks,
 
Dave
Price Book Entry object -  update custom field when record created or edited

Normally, I would start with the process builder. However, the object is not available in the process builder. So I checked Flow and it was still not available.


How can I change a custom field value based on a specific criteria when a record is created or edited???

Can I do this without using APEX code?

Thanks,

Dave
Hi All,

Using SOQL query below which shows all field IDs for all custom fields.

Select Id, DeveloperName from CustomField

How can I limit this SOQL query to only show Field IDs for a specific object? for example to case object?

Thanks,

Dave the Rave
Created a form in our Umbraco CMS system using Contour Forms. Idea is that when the form is submitted via our website a case is created using the web-to-case functionality.

No case records are being created at the moment and there are no error messages.

In the form all fields have been setup and their are some hidden fields to insure the OrgID and other obligatory field values go to Salesforce. The endpoint url is set and was created using the HTML generator in Salesforce.

The problem is no case records are being created? Has anyone else had this issue? or can suggest what the issue might be?
Hi all,

I am struggling with validating input on a form. I am cutting and pasting the code below into a CMS system:

The form is submitting to SF even if you do not fill any fields in.

Does anyone have a solution:
 
<html>
<head>
<script>
function validateForm() {
  var x = document.forms["myForm"]["fname"].value;
  if (x == "") {
    alert("Veld verplicht*");
    return false;
  }
}
</script>
</head>
<body>

<form name="myForm" action="https://ako--abc.my.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8"  onsubmit="return validateForm()" method="post">

<input type="hidden" name="orgid" value="00D0Q0000008i66" /> 
      <input type="hidden" name="retURL" value="https://www.vierhetseizoen.nl/contact/bedankt" /> 
      <input type="hidden" name="status" value="New" /> 
      <input type="hidden" name="requesttype__c" value="Inbound" /> 
      <input type="hidden" name="type" value="Question" /> 
      <input type="hidden" name="recordtype" value="Order" />
      <input type="hidden" name="webcountry__c" value="NL" />

      <!-- Fields above not viewable in form but hidden data transmitted to SF case record  -->
      
      <div style="width: 90%; margin: auto;">
            <p style="padding:0px; margin-left: 5px;">name</p>
            <input id="b1518536294940" name="Voornaam" type="text" placeholder="Voornaam *" value="" data-type="text" required=true/>
 

          </div>

   <!-- Code for required fields test -->
   <br /> 

  <input type="submit" value="Submit">
</form>

</body>
</html>



Thanks Dave
I would like to visualize SAP data in an External Object in the Sales Cloud.

Using Salesforce Connect is it possible to connect SAP PO to Salesforce? Is it possible to connect SAP ECC directly?

Thanks,

Dave
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
The REGEX code below works perfectly, but I now need to allow for the email field also to be blank.

NOT(REGEX(Email ,('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+')))

Can I incorporate NOT ISBLANK( Email ) into the statement above so:

A user can enter an email in the correct format as above or the user does not have to enter an email address at all?

Thanks,

​​​​​​​Dave

 
As a admin, I have created a DML Statement to run in the Developer Console adhoc whenever I need to change account record owners en mass.

Now I need to convert that into an Apex Class and Trigger so that when records are uploaded from an external party the account record owner will be changed automatically based on shippingcity. See DML Code below:
 
List<Account> recList = [select id, shippingcountry, ownerid, name, shippingcity FROM Account WHERE shippingcountry = 'NL' AND sasid__c = null and ownerid='0052o00000AHDCeAAP' AND shippingcity IN ('Nijmegen','Arnhem')];
for (Account rec : recList) {
rec.ownerid = '0052o00000AI4zfAAD';
}
update recList;

3rd Party OwnerID = '0052o00000AHDCeEAP'
New record owner = '0052o00000AI4zfACD'
As a an admin, I am using the Developer Console to execute an SOQL query. The aim is to count the number of records on the lead object where the text fields  "Name = firstname and lastname" and "Company" have the same values.

I wrote this query, but got an error

SELECT Id, firstname, lastname FROM lead WHERE [lastname + firstname = Company]

After searching Google, it seems that the goal is not achievable using SOQL, can anyone confirm this? is there another simple solution using Apex run from the developer console?

For example firstname & lastname = "Peter Smith" AND Company = "Peter Smith",  so this is one record where the name and company are the same.

Thanks,

Dave
I would like to add a column to all existing listviews on the case object. After some searching in Google, I understand that it is possible to amend the metadata of the listview object.

The question is how to do this? 

The addition column is SuuportedVendor__c

Thanks,

Dave
Hi Salesforce developers,

As an admistrator, I need to add one new custom field to all listviews e.g. sharedvendor__c from the case object. There are over 50 different list views.

How can I do this in the most efficient way? I think this might require a DML statement or apex class, but cannot find the answer in any forum.

Can you help?

Dave



 
Created a form in our Umbraco CMS system using Contour Forms. Idea is that when the form is submitted via our website a case is created using the web-to-case functionality.

No case records are being created at the moment and there are no error messages.

In the form all fields have been setup and their are some hidden fields to insure the OrgID and other obligatory field values go to Salesforce. The endpoint url is set and was created using the HTML generator in Salesforce.

The problem is no case records are being created? Has anyone else had this issue? or can suggest what the issue might be?
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();
    }
}


 

Dear Guru's

 

I have configured some batch processes to load data into SFDC using the dataloader from the command line.....all works well....however, my source file has comma's in the data. Since the data loader reads from a CSV file, how can I configure it to know that the comma is actually part of a data attribute and not the delimiter.

 

Is there a special character I can write to the source file so that a comma is considered part of the record?

 

Thanks

 

 

  • June 02, 2011
  • Like
  • 0