-
ChatterFeed
-
0Best Answers
-
3Likes Received
-
0Likes Given
-
6Questions
-
7Replies
How to define a File object and read it in Apex
For example, the following show how to upload files using a visualforce page -- but I need to know how to define the File in Apex then read it.
https://reddymallareddy.blogspot.com/2017/08/read-and-insert-records-from-csv-file.html
http://sfdcsrini.blogspot.com/2014/04/how-to-read-csv-file-from-apex_17.html
I want to have code that basically does the following:
File xyz = 'accountData.txt' ;
csvFileLines = new String[]{};
acclist = New List<Account>();
String csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1; i < csvFileLines.size(); i++){
Account acct = new Account();
string[] csvRecordData = csvFileLines[i].split(',');
acct.name = csvRecordData[0] ;
acct.accountnumber = csvRecordData[1];
acct.Type = csvRecordData[2];
acct.AccountSource = csvRecordData[3];
acct.Industry = csvRecordData[4];
acclist.add(acct);
}
Can anyone provide any real working, comprehensive code that
1. Creates the file or static resource
2. In another class reads that file or static resource and loads it into
I have been searching all over the net for examples, but can't find anything that is 100% apex. Please do not just point me to the documentation (most of it is worthless) -- I need real code examples (that work), not just snippets of code.
- Stuart Fleming
- October 03, 2018
- Like
- 0
- Continue reading or reply
pass dateTime parameter to Apex Query
@AuraEnabled
public static List<ice_Cream_Order__c> getIceCreamOrdersByContactTime(Id contactId, DateTime createdWhen){
return [ select Id, How_Many__c , Ice_Cream_Flavor__r.Name, Contact__c , Contact__r.Name
FROM ice_Cream_Order__c
where Contact__c = :contactId AND createdDate >= :createdWhen];
}
At issue: The table shows no data. I assume it is an issue of the Flow DateTime value of 2018-06-18T15:42:53.986Z does not correspond to the apex sql.
Would anyone have any suggestions on how to pass the dateTime variable to the apex method?
Thanks,
stuart
- Stuart Fleming
- June 18, 2018
- Like
- 0
- Continue reading or reply
Trailhead Discover Lightning Actions - CreateUser.cmp does not save
I have attempted to do this tralhead for about 3 weeks now -- sent in some feedback, but no change seems apparent in the tralhead.
1. I created a brand new "My Trailhead Playground 2"
2. Open the Developer console.
3. Create a Lightning Component called CreateUser.cmp
4. Copy the text in for this code.
5. Press Save
6. Get Error. Failed to save CreateUser.cmp: Invalid <aura:attribute> type: Test_User__c: Source
In order for this to save, I had to create an object Test_User (Test_User__c) with the following fields:
First or First__c
Last or Last__c
Nickname or Nickname__c
Email or Email__c
Password or Password__c
I also had to change several lines of code to reflect the Field name xxx__c rather than what was listed in the tralhead.
value="{!v.user.First}" to value="{!v.user.First__c}" etc.
I haven't finished with the tralhead examples...but I hope this will work.
Would someone please update the tralhead or fix it?
Thanks,
Stuart
- Stuart Fleming
- April 18, 2018
- Like
- 3
- Continue reading or reply
How to complete LTNG_SecureFilters_Challenge
I am stuck on the https://trailhead.salesforce.com/modules/security-for-lightning-components/units/secure-your-lightning-java-script-code challenge.
After searching on the internet, I am unable to find a solution. I found a link https://developer.salesforce.com/forums/?id=9060G000000UbhwQAC but I am not sure what solution in it works. (And I found another web page referring this same url saying "Jeff" had found a solution..but it did not work for me. Here is what Jeff first says:
Trying securing the description instead: secureFilters.html(results[i].Description__c)
I tried that and get this message:
Challenge Not yet complete... here's what's wrong:
The 'LTNG_SecureFilters_Challenge' component does not appear to be requiring the secureFilters resource.
Further in the post the person who asked the question says this: "That worked. Thanks."
And then he summarizes and says would this be OK:
secureFilters.html(results)
And Jeff replies, "Correct".
So I tried doing this:
var results = response.getReturnValue() ;
secureFilters.html(results) ;
And this created an error.....
And I tried this (thinking that maybe it needs to be passed to a variable) :
var results = response.getReturnValue() ;
results = secureFilters.html(results) ;
And this created an error.....
Can anyone please help?
Thank you,
Stuart
- Stuart Fleming
- April 04, 2018
- Like
- 0
- Continue reading or reply
is there a wysiwyg editor for lighting components?
While some people might like developing in a notepad like editor, I expected a whole lot more out of salesforce. In the developer console aren't even drop downs to fill out expected results.... I don't see much more in the eclipse force.com plugin.
This seeming complete lack of productivity features is a big letdown. Am I missing something, or is this a complete bust?
- Stuart Fleming
- February 06, 2018
- Like
- 0
- Continue reading or reply
Customize Compact Layouts unexpected error
I am getting the following warning message after checking the challenge:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: IREOKHWT
I had some problems accessing my developer org earlier, and had to disconnect it.
Given that this assignment relies on previously created objects and such, I can't just create a new Developer Edition.
Any ideas?
Thank you,
Stuart
- Stuart Fleming
- January 24, 2018
- Like
- 0
- Continue reading or reply
Trailhead Discover Lightning Actions - CreateUser.cmp does not save
I have attempted to do this tralhead for about 3 weeks now -- sent in some feedback, but no change seems apparent in the tralhead.
1. I created a brand new "My Trailhead Playground 2"
2. Open the Developer console.
3. Create a Lightning Component called CreateUser.cmp
4. Copy the text in for this code.
5. Press Save
6. Get Error. Failed to save CreateUser.cmp: Invalid <aura:attribute> type: Test_User__c: Source
In order for this to save, I had to create an object Test_User (Test_User__c) with the following fields:
First or First__c
Last or Last__c
Nickname or Nickname__c
Email or Email__c
Password or Password__c
I also had to change several lines of code to reflect the Field name xxx__c rather than what was listed in the tralhead.
value="{!v.user.First}" to value="{!v.user.First__c}" etc.
I haven't finished with the tralhead examples...but I hope this will work.
Would someone please update the tralhead or fix it?
Thanks,
Stuart
- Stuart Fleming
- April 18, 2018
- Like
- 3
- Continue reading or reply
How to use flow variables in apex class
- Eswari_12
- September 15, 2018
- Like
- 0
- Continue reading or reply
pass dateTime parameter to Apex Query
@AuraEnabled
public static List<ice_Cream_Order__c> getIceCreamOrdersByContactTime(Id contactId, DateTime createdWhen){
return [ select Id, How_Many__c , Ice_Cream_Flavor__r.Name, Contact__c , Contact__r.Name
FROM ice_Cream_Order__c
where Contact__c = :contactId AND createdDate >= :createdWhen];
}
At issue: The table shows no data. I assume it is an issue of the Flow DateTime value of 2018-06-18T15:42:53.986Z does not correspond to the apex sql.
Would anyone have any suggestions on how to pass the dateTime variable to the apex method?
Thanks,
stuart
- Stuart Fleming
- June 18, 2018
- Like
- 0
- Continue reading or reply
How to complete LTNG_SecureFilters_Challenge
I am stuck on the https://trailhead.salesforce.com/modules/security-for-lightning-components/units/secure-your-lightning-java-script-code challenge.
After searching on the internet, I am unable to find a solution. I found a link https://developer.salesforce.com/forums/?id=9060G000000UbhwQAC but I am not sure what solution in it works. (And I found another web page referring this same url saying "Jeff" had found a solution..but it did not work for me. Here is what Jeff first says:
Trying securing the description instead: secureFilters.html(results[i].Description__c)
I tried that and get this message:
Challenge Not yet complete... here's what's wrong:
The 'LTNG_SecureFilters_Challenge' component does not appear to be requiring the secureFilters resource.
Further in the post the person who asked the question says this: "That worked. Thanks."
And then he summarizes and says would this be OK:
secureFilters.html(results)
And Jeff replies, "Correct".
So I tried doing this:
var results = response.getReturnValue() ;
secureFilters.html(results) ;
And this created an error.....
And I tried this (thinking that maybe it needs to be passed to a variable) :
var results = response.getReturnValue() ;
results = secureFilters.html(results) ;
And this created an error.....
Can anyone please help?
Thank you,
Stuart
- Stuart Fleming
- April 04, 2018
- Like
- 0
- Continue reading or reply
Customize Compact Layouts unexpected error
I am getting the following warning message after checking the challenge:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: IREOKHWT
I had some problems accessing my developer org earlier, and had to disconnect it.
Given that this assignment relies on previously created objects and such, I can't just create a new Developer Edition.
Any ideas?
Thank you,
Stuart
- Stuart Fleming
- January 24, 2018
- Like
- 0
- Continue reading or reply
Custom Metadata Types Use Metadata Relationship Fields - Rules Engine
Create Custom Metadata Type Records
For SFA Field, enter Minimum Support Level.
I only see the Support Level field that was created on the account. Also, I don't see that this is actually limiting the chosen fields (seems like that was the point of all of the new metadata fields). Is there something I am doing wrong here, or is the example off?
Also, if anyone has built out a rules engine while referencing metadata, I'd love to see a link to an example of that.
- Starley Flynn 11
- November 10, 2017
- Like
- 0
- Continue reading or reply
How to insert delay in apex class?
I am new to salesforce. I have an apex class from where I am calling a web service. I want to insert the delay of 10 sec so that I can handle the 'over query limit' error.
thanks in advance!
- Sandesh D Ganjare
- December 21, 2015
- Like
- 0
- Continue reading or reply