• Hugh Wheeler 46
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Director
  • Cloud Masons


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hi there,

I am using flows quite heavily in an application, because we have so much regulatory compliance that changes often, I am putting the logic in flows and calling from process builder or apex.  The latest one I am working on is quite simple in theory.  I have to query about 50 fields on 1 custom object and use them to create another custom object or update it if it is there.  This is stuctured as follows:

1.  Sceduled apex kicks off a class
2.  Class Queries for all records changed
3.  Loops through each passing them into a flow.  The flow creates the new records and returns the record to the apex
4.  Once all records are processed, the apex upserts the list of all records.

My problem comes inside the flow when I have a custom text field (10) on each object.  If it is blank on the source object I get an error:

The flow failed to access the value for sObjVariable.FieldName__c because it hasn't been set or assigned.  

I found a useful hack in process builder to get around this kind of thing with lookup fields the other day where you insert a formula testing for null, and setting the field to null if it has no value.

This same workaround does not seem to work in flow.  No matter what I do I get the same error.

I have output everything in the calling apex and the field value is null, but the object i am passing into the flow is populated.  Someone must have run into this and solved it before.  Process builder seems to handle this kind of situation, but flow just dies.  Any assistance would be appreciated.
Hi there,

I have been trying to get some code to pass the check marks scanner.  I have nailed most of it, but am getting two issues that I think may be false positives, but cannot find much information on them.

Issue 1.

The scanner is picking up the following line:

newRecord.Id = currentRecord.Id;

Then it is picking up the upsert line where this object is inserted or updated in the database.

upsert newRecord;

I have this wrapped in tests for 

1.  isUpdateable() (On the object)
2.  isCreatable() (On the Object)

3.  isUpdateable() on each field except Id
4.  isCreatable() on each field.

It doesn't make much sense to me to wrap the Id field in isCreatable() or isUpdatable(). And when I do wrap the Id field it behaves as I would expect and acts as though you dont have create or update access.

Has anyone else run across this one?

Issue 2.

I have a cross site scripting error on the apex:page tag.

<apex:page controller="SMSPageController" docType="{!HTMLENCODE('html-5.0')}" sidebar="{!HTMLENCODE('false')}" showHeader="{!HTMLENCODE('true')}">

I added the HTML encoding to the parameters, because I thought that was what it was complaining about.

Has anyone else run into this one?

Any help would be greatly appreciated.
Hugh


 
I have started using 'Flows' for the first time and have some questions about it:

1) Showing more than 200 records in a Dynamic Record Choice
I am trying to create a 'Dynamic Record Choice' that lists all Countries that exist in the custom Country__c object. However since there are over 200 records in this table (and the limit that 'Dynamic Record Choices' display is 200), I was trying to do a workaround I found online, by creating separate, smaller 'Dynamic Record Choice' lists, and then merging them.

So I tried to create a 'Dynamic Record Choice' that had all the countries listed from A to J and then another from K to Z, however I cannot seem to add an filter logic to the 'Dynamic Record Choice' to return all Countries whose 'Name' starts with A or B or C,etc. http://screencast.com/t/lPXzcvXg.

Is there any way i can do this, or another approach you can suggest to get my 200+ countries in a picklist for the flow?

2) Setting field value not ID
For the same 'Dynamic Record Choice, i am storing the value of it's ID field. I then use it when i create the new Account (step 2 of the flow) - i actually use it twice in that 'Record Create' step http://screencast.com/t/ZQU5K6lfC.

When it is used to set the 'Country__c' field on the Account, it works as expected (as that field is a lookup). However, when i use it for the 'BillingCountry' field, i want it to set the value of the 'Name' of the Country record, not the ID. Is there any way to do this?

3) Exiting a Flow
After a Flow is finished, how do i get it to return to the new record it just created?

I have tried doing this by adding a hyperlink label on the Finish screen to go to https://eu1.salesforce.com/{!NewAccountID}, however when this is clicked, it just loads the page in a new browser window, and leaves the Finish screen of the Flow open.

4) Replacing the New Account button
Is there any way to replace the 'New' button that appears in the 'Recent Accounts' list, with a custom button that launches this Flow? http://screencast.com/t/ZyrNCq9fF I do not want uses to create New Accounts using the standard process; i only want them to use this Flow. 
With a lot of help from the forum over the past week, I have a custom button that performs a series of functions on the Opportunity object

 1. It copies 6 fields to six custom fields
 2. It clears the 6 fields
 3. It copies all Opportunity Line Items to a Custom field
 4. It deletes all Opportunity Line Items

It seems like item 4 sometimes fires before 3 has completed so, the Opportunity line Items never make it into the custom field.

Realizing I'm a noob, is there an easy remedy? Maybe have a message box popup that fires the code for Item 4 on it?
The code below works fine concatenating PriceBook.Entry.Product2.Name on seperate lines of a custom field with a comma at the end of each line.

I need to add Quantity and TotalCost for each Opportunity Product Line item to each line of the custom field and seperate the values with a space hyphen space like this:

PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,
PricebookEntryProduct2.Name - Quantity - TotalCost,

When I try to add Quantity and TotalPrice like this, I get a "Quantity not defined" error
 
var strProductNames = '';
for(var i=0; i<retriveOpptyLineItems.records.length ; i++){
strProductNames += retriveOpptyLineItems.records[i].PricebookEntry.Product2.Name, Quantity, TotalPrice + ',' + '\n ';
}


 
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
var record = new sforce.SObject("Opportunity");
record.Id = '{!Opportunity.Id}';
var retriveOpptyLineItems = sforce.connection.query("Select PricebookEntry.Product2.Name, Quantity, TotalPrice From OpportunityLineItem WHERE OpportunityId = '{!Opportunity.Id}' and (NOT Name like '%Discount%')");
 
var strProductNames = '';
for(var i=0; i<retriveOpptyLineItems.records.length ; i++){
strProductNames += retriveOpptyLineItems.records[i].PricebookEntry.Product2.Name + ',' + '\n ';
}
 
//eliminate the last ','
if(strProductNames.length>0){
strProductNames = strProductNames.substring(0,strProductNames.length-1);
}
record.Sample_Product_Name_1__c = strProductNames;
sforce.connection.update([record]);
window.location.reload();
Hi there,

I have been trying to get some code to pass the check marks scanner.  I have nailed most of it, but am getting two issues that I think may be false positives, but cannot find much information on them.

Issue 1.

The scanner is picking up the following line:

newRecord.Id = currentRecord.Id;

Then it is picking up the upsert line where this object is inserted or updated in the database.

upsert newRecord;

I have this wrapped in tests for 

1.  isUpdateable() (On the object)
2.  isCreatable() (On the Object)

3.  isUpdateable() on each field except Id
4.  isCreatable() on each field.

It doesn't make much sense to me to wrap the Id field in isCreatable() or isUpdatable(). And when I do wrap the Id field it behaves as I would expect and acts as though you dont have create or update access.

Has anyone else run across this one?

Issue 2.

I have a cross site scripting error on the apex:page tag.

<apex:page controller="SMSPageController" docType="{!HTMLENCODE('html-5.0')}" sidebar="{!HTMLENCODE('false')}" showHeader="{!HTMLENCODE('true')}">

I added the HTML encoding to the parameters, because I thought that was what it was complaining about.

Has anyone else run into this one?

Any help would be greatly appreciated.
Hugh