• Stuart Fleming
  • NEWBIE
  • 35 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
I am creating apex classes that will query our prod instance for sample data.  It will create a file or a static resource.    Then when I create the sandbox, I run a apex script that reads the file and uploads the data into the sandbox objects.
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.
 
Hi.  I have created a flow that shows a number of orders that a person is making.  The first thing the flow does is assign the flow {!$Flow.CurrentDateTime} to a variable called NowVariable.  The next screen the user enters the order.  The final screen the user sees a lightning component table that shows the orders the person made (passing in the contact and NowVariable).  The lightning component controller is an apex class:

     @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
Hi.  I am doing the tralhead https://trailhead.salesforce.com/modules/lex_javascript_button_migration/units/javascript_buttons_to_lightning_actions

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


 

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

Hi.  I am new to Salesforce and am evaluating it for our organization.  I am currently working on the Lightning Modules in Trailhead.

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?

 
I am working on the trailhead https://trailhead.salesforce.com/modules/salesforce1_mobile_app/units/salesforce1_mobile_app_compact_layouts

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

 
Hi.  I am doing the tralhead https://trailhead.salesforce.com/modules/lex_javascript_button_migration/units/javascript_buttons_to_lightning_actions

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


 
The flow should call apex class to create new record. The field values are given in flow screen, the class should get the values to create record. I'm having trouble in passing the flow variable to class. How to use the flow input values in apex class. Can anyone help me out in this please.
Hi.  I have created a flow that shows a number of orders that a person is making.  The first thing the flow does is assign the flow {!$Flow.CurrentDateTime} to a variable called NowVariable.  The next screen the user enters the order.  The final screen the user sees a lightning component table that shows the orders the person made (passing in the contact and NowVariable).  The lightning component controller is an apex class:

     @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

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

I am working on the trailhead https://trailhead.salesforce.com/modules/salesforce1_mobile_app/units/salesforce1_mobile_app_compact_layouts

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

 
So on this page about halfway down it states: 
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.
Hi,
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!