Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. In Apex it is considered as any set of characters surrounded by single quotes.

-3
votes
1answer
42 views

Apex trigger, return string, calling methods and code correction needed

Please explain what is wrong as I have problems writing methods, and correct the code if you can. Error: Compile Error: Variable does not exist: a at line 11 column 16 trigger tokenGenerator on ...
0
votes
1answer
22 views

replace function not working

Hi replaceAll function in apex, is not replacing every occurance in my string. Can anyone guide me on this, how to replace every occurrence in string? string body='<p>string 1</p><p>...
0
votes
1answer
21 views

Invalid conversion from runtime type String to Double

Background I am getting this error: Invalid conversion from runtime type String to Double On this line of code: line.put(targetField, (Double)fieldValue); The variable fieldValue is of type ...
2
votes
1answer
91 views

Replace double quotes with single quote in a JSON string

We have JSON sent to us by webservice which has double quotes in value part (Key => Value)in the JSON String. Below is how the JSON looks like [{ "dp_id": "SDN071076", "list1": "...
0
votes
2answers
26 views

incrementing a number followed by a letter. eg A1, A2, A3 only. Under process builder formula field [closed]

I'm using the process builder for a certain task. Which will check a field of a record, if it's value is A1, it will create a new record and set it to A2, if A2 then set it to A3, and if A3 then ...
5
votes
3answers
200 views

JSON Parser getCurrentToken()

I have a JSON string that I want to parse out. I have use the below code many times but for whatever reason this time it is not working. Can anyone poke any holes in this logic? Or point out why this ...
1
vote
1answer
23 views

Only Start of Confirmed Built String Displays in Confirmation Popup Via Visualforce

With each inputCheckbox on my VF page checked, I'm adding to a string in my controller: public with sharing class ApplicationServerMonitorController { public String contactsAboutToEmail {get;set;...
1
vote
1answer
93 views

String starts with anything in a set<String>?

I want to see if any of the strings I pass(num) starts with any of the values on my set Ex. String num = 456987533; Set<String> numValidator = new Set<String>{‘456’,’312’,762’}; ...
1
vote
1answer
109 views

lightning component empty field check?

<aura:attribute name="guid" type="String" default="{!v.simpleRecord.Loan_Guid__c}"/> <aura:attribute name="fileCreated" type="Boolean" default="{!v.guid != '' ? true : false}"/> ...
0
votes
2answers
24 views

Unable to convert phone to string in apex

I am working on rest API services. I need to push phone number as a string in the body of the request. I tried following way. String Str1=ts.phone.replaceAll('(',''); String Str2=Str1.replaceAll(')',...
1
vote
2answers
88 views

Generate random string using Crypto.generateAesKey?

I need to generate an unique alphanumeric string of length of 30 characters which will be used very similar to the record id. Is it okay to use Crypto.generateAesKey() method to generate this 30 ...
4
votes
1answer
159 views

Accommodate the length of a string value to prevent the STRING_TOO_LONG issue

I received an exception while trying to insert an order item. It appears to be that the description field allows only 255 characters; sometimes my descriptions goes beyond 255. I will shorten the ...
0
votes
0answers
23 views

Problems with displaying strings in layouts

I added a section to a standard layout in which I entered several fields. I have a string field in which spaces can not be inserted and the value can be very long (255 characters) the layout brings ...
1
vote
3answers
316 views

How to sort a list of strings in the descending order?

I'm trying to sort the list of strings which has versions but fail to do this: List<String> src = new List<String>{'7.1.2', '8.1.3', '11.0.5', '5.x', '10.0.89', '12.13.14'}; List<...
2
votes
1answer
88 views

Split a row with data separated by “,”

I need to split a row from a DE. The row contents 4 strings, and I want to see the content in a table. Right now I have some code; but doesn't work: Script %%[ VAR @Productos<br/> SET @...
0
votes
1answer
436 views

String replace double quotes & slash

I'm trying JSON Parser and in the JSON I've \" (for like <tag style=\"color: #fff;\"...) If I can replace \" with \\" the parser works fine (like in this - https://developer.salesforce.com/forums/?...
0
votes
2answers
41 views

How to replace both space and newline form the string using regex

lstIQCodes = IQcodeString.replaceAll(' ','').split(','); I have tried the above code and able to replace spaces and now I want to replace newline as well.
2
votes
1answer
220 views

Date Json.serialize removes 00:00:00 digits from datefields of object

I have the following object (invMappingNew): {customerId__c=1, addressId__c=8212BJ154, invoiceType__c=AdvancePayment, invoiceTypeLocalized__c=Voorschot, invoiceDate__c=2015-02-13 00:00:00, ...
2
votes
1answer
325 views

How to return Json string

I have a Get Method which returns an invoice based on id. When I test this with Workbench I would like to have the following response: { "customerId": "1", "addressId": "2018AA123", "invoiceId": "...
1
vote
1answer
120 views

isNotBlank(inputString) vs isNotEmpty(inputString)

For string in Apex code, I can see two functions to check if string has any value or not: isNotBlank(inputString) and isNotEmpty(inputString). I have following questions regarding two similar looking ...
2
votes
1answer
208 views

Convert Schema.SObjectfield to string

I have a List of Schema.SObjectfield and I want to convert it to String. I am getting below error. System.JSONException: Apex Type unsupported in JSON: Schema.SObjectField Here is my approach. ...
2
votes
1answer
220 views

JSONGenerator writeObjectField() remove backslashes

I'm trying to create an Invocable Method which allows an input of a JSON-formatted string from Process Builder as a variable. However, when I try to add the inputted JSON string using JSONGenerator....
2
votes
1answer
141 views

How do I check if substring is out of bounds?

I'm trying to find a way to check if a substring causes an out of bounds error in an If statement This is what I have got so far but if the original string has less than 8 characters after substring ...
1
vote
1answer
394 views

Parsing of JSON where a key contains spaces

I am trying to deserialize this response { "invoiceList":[ { "totalPrice":5.5, "statementDate":"2011-10-04T16:58:54.858Z", "lineItems":[ { ...
3
votes
2answers
366 views

How to Pass in an Array of Strings in a Method Parameter in a Test Class

I'm writing a test class right now, and I'm calling a method in the class that I am wanting to test. The method in the main class that I'm wanting to test is called getTruckerAvailability(). Here is ...
0
votes
1answer
33 views

how to get perticular string from json String

Below is my json string getting response from server. in this strig i want alternateLink String part which is "https://drive.google.com/file/d/2ferg6YSxertrewtaN_1iZc/view" how i can get this in ...
1
vote
1answer
29 views

Convert String to Method for use with Datetime

How do I convert a string into a method? I am building a method in a string using custom setting variables. Datetime now = Datetime.now(); update_settings__c updateSettings = [SELECT ...
0
votes
1answer
16 views

Substring based on a word and immediate next third bracket

I have a large text value as below in a custom field of a custom object. FINDDATA: [XY_8852376....... {name:"State__SKN", "data": "State__SKN", defaultContent: '', className:"frozencolumnscolor", ...
2
votes
1answer
53 views

How do I set a string field to null in a Big Object using Apex?

Is that something that is not allowed? Is it a bug? I just tried and it did not seem to set anything. The index of Named_Entity_Big__b is over the following, and I'd like to set Result__c to null: ...
0
votes
2answers
67 views

How to make apex class dynamically AuraEnabled

I am trying to add @AuraEnabled annotation to apex class dynamically without any manual intervention. I have used below soql to fetch the body of the apex class. ApexClass classNameList = [SELECT ...
0
votes
1answer
279 views

Check For Special Characters in Emails

I'm having a business requirement of searching special characters in Email Field(before @domain.com)in a trigger. For Ex: if a email is like this (t#@est@gmail.com).it should be able to identify the'#...
0
votes
3answers
36 views

unable to convert string to integer datatype

I'm trying to convert String to Integer datatype. But I'm unable to convert. I know its simple, but getting me problem here. It giving me below error FATAL_ERROR|System.TypeException: Invalid ...
3
votes
1answer
301 views

Using single quote by curly braces in String.format in Dynamic SOQL

I'm struggling to use String.format to replace a token with a value when the token is within single quotes: Example: String query = String.format('SELECT Id FROM Availability WHERE Person__c = \'{0}\...
1
vote
1answer
200 views

Facing “common.apex.runtime.impl.ScalarList@a1324f1f”

I have a child object to contact called"ObjectA".I have a discipline field(text) in the child object and I have the same field in Contact too.Now If I insert 4 child records with different contact ids,...
2
votes
1answer
21 views

How To get dom documenet value list

Http h = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setHeader('Content-Type', 'text/xml'); req.setHeader('SOAPAction', action); req.setEndpoint(ep);...
0
votes
1answer
172 views

System.QueryException: unexpected token: :

I have a class where I get 2 variables from a lightning component as a string which works fine. When I try to pass these variables from my testclass I get the error System.QueryException: unexpected ...
-3
votes
1answer
96 views

How to escape html characters in long text area field

I have a requirement where i need to copy the contents of a contentnote to a longtextarea field called 'comments' using apex anonymous. The issue is i am getting the following HTML characters for ...
-2
votes
2answers
57 views

How to set string query using not equal to empty?

contact c=[select id,firstname,lastname ,email from contact where email !='']; above query how to set string query.Please anybody help on this
0
votes
1answer
79 views

patern and matcher not working

I am using regex to find line which starts with 'aaaa' pattern myPattern = pattern.compile('^(aaaa)\b.*'); String a = 'aaaa,777,ttttt,rrrrrr'; a += '\n' + 'tttttt,ttttt,0000'; matcher myMatcher = ...
3
votes
0answers
91 views

What method can be used rather of “getBytes()” in salesforce, this method basically changes string to byte

Below is code snippet from C# which needs to be converted in Apex: var key = Encoding.UTF8.GetBytes("string");
0
votes
0answers
23 views

String exception for a closing third bracket

I have below code where I am passing multiple Account Ids as selected from VF Page to controller. But surprisingly I am getting a closing third bracket appended to the string. I need to remove it ...
3
votes
1answer
428 views

How to add string values using apex?

I have two string values using numbers. How to add(not concatenate) the two string values. Could you please help me. my code: string num='2016'; system.debug('first:'+num); Output: 2016 string num1=...
1
vote
1answer
73 views

Trying to set a record's value based on a field via string. Is this dynamic approach possible in Salesforce?

Apologies if this was already answered, but I didn't see a clear cut solution for this issue in Salesforce. I want to be able to dynamically set values for a record based on a predefined list of ...
1
vote
1answer
192 views

Convert double to String

I have the following double from salesforce as a number = Latitude = 50.916408140415314 I want to convert it to a string. However when I convert it to a string like this: string.valueof(latitude) i ...
0
votes
1answer
42 views

Create a class and a static function which take classid as argument and returns all names of the students in that class as a list

i created an apex class where i pass the class name and it will give me a list of all the students in it but i want to give className as string but it's only taking the id of the class. Here ...
6
votes
1answer
64 views

Detect whether a string contains characters that will not be saved into sObject text field

As a simple example, consider the following string, where I can assign it to an sObject field and it retains the original value, but after inserting the sObject, the value returned when querying the ...
0
votes
1answer
105 views

getting scientific notation when converting from string to blob to save to csv

I have a long string that I want to save to CSV. I use the following code to convert the string to blob and save as a file: Attachment newFile = new Attachment(); newFile.Name = getReportFileName(); ...
2
votes
1answer
700 views

Array of String values to get inserted into TextArea field

I am having a list of contact names in an array of String. I am trying to insert those names into a Text area field while inserting the record, but getting an error. How can I implement this? Is ...
-1
votes
1answer
73 views

How to convert fields values from String to DateTime format?

Actualy I'm inserting data into custom object through REST api I got some time fields like date begin and date end fields these two fields from api response <date-begin>2017-12-...
5
votes
2answers
2k views

How to truncate a string to a specific length if it is longer?

How can I make it that I can reduce the length of a String? Like for example the string.Length() = 300. My goal is to make it to 120 characters, retaining the left side (e.g. NameOfThePerson to ...