function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WhyserWhyser 

How to enter carriage returns when inserting or updating?

I've been scouring the search option for help on this topic, but there doesn't seem to be any topics in regards to this.
 
I'm using C# .NET to update the Opportunity Competitor's strengths and weaknesses fields, based on the competitor they have selected from the picklist.
 
When there is more than one strength or weakness for that competitor, I tried to insert a carriage return to the text.
 
For example
 
Code C#:
QueryResult qr = sfdc.query("Select Id, CompetitorName, Strengths, Weaknesses From OpportunityCompetitor Where IsDeleted = false and OpportunityId = '" + OpportunityId + "'");

OpportunityCompetitor[] OppCompetitorList;

// Go though all the competitors in the opportunity
for ( int i = 0; i < qr.records.Length; i++ )
{
  // Iterate through each of the Competitor's strengths
  // competitorHash allows me to do a lookup in my competitors table to retrieve all the strengths and weaknesses for that object
  for ( int j = 0; j < competitorsHash[OppCompetitorList[i].CompetitorName].Strengths.Length; j++;)
  {
    OppCompetitorList[i].Strengths += OppCompetitorList[i].Strengths == "" ? competitorsHash[OppCompetitorList[i].CompetitorName].Strengths[j].Value : "\r\n" + competitorsHash[OppCompetitorList[i].CompetitorName].Strengths[j].Value;
  }
}

The main focus of my code is where I have "\r\n". I thought I could use this to add carriage returns or new lines or whatever into the strengths/weaknesses, but after updating, when I look at my results, it displays all the text as one line.
 
I'm sure people MUST have run into this problem before. How in the world do you update/insert a carriage return into a multi-line text field???
werewolfwerewolf
If you manually add a carriage return to such a field and request it via the API, what characters show up for the linefeed?  Perhaps just emulate that exactly?
WhyserWhyser
Perhaps this is a bug with just those fields.
 
I have tested the "\r\n" with other fields in Salesforce, and I'm having no issues getting carriage returns after inserting/updating to Salesforce.
 
When I manually add a carriage return from the Salesforce GUI, and then return it via the API, I get the carriage returns.
 
Here's an example of what I did for testing:
 
The Strengths field had the following text entered manually:
 
test Strength 1
test Strength 2
test Strength 3
 
Now what I did was retrieve the data via API, and the do an update using the queryResult records I got from the query call. No values were changed or modified, and yes there were carriage returns in the recordset.
 
After updating the exact same values back to Salesforce, I get:

test Strength 1 test Strength 2 test Strength 3
 
I'm pretty sure this isn't supposed to happen.