• Zac Rosenberg
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies
Hello,

I'm having issues communicating to a nested component. I would like a component to be able to run a method in the nested-component's controller.js (or helper). I have tried both events and via and no luck. Here is the example markup:
 
<!-- myEvent.evt --> 
<aura:event type="APPLICATION"> 
</aura:event> 

<!-- super-component --> 
<aura:component>
    <aura:registerEvent name="myEventName" type="c:myEvent"/> 
    <c:my_Nested_Component /> 
    <ui:button press="{!fireEvent}" 
<aura:component> 

//super-component_controller.js 
({ 
    fireEvent: function(component){ 
        var myEvent = component.getEvent("myEventName"); 
        myEvent.fire(); 
        console.log('event fired'); 
    } 
}) 

------------------------------------------ 

<!-- nested-component --> 
<aura:component> 
    <aura:handler name="myEventName" event="c:c:myEvent" action="{!c.gotEvent}" /> 
<aura:component> 

//nested-component_controller.js 
({ 
    gotEvent: function(component, event){ 
        console.log('received event!'); 
    } 
})

This does not work. I tried the same exact code that I placed on the nested-component on a super-super-component, and it worked perfectly.The super-super component received the event. But the nested component is not able to. I figured this had to do with events only bubbling up (though the documentation does say that that is only the case with Component events, not application events).

So the other option I read online is using . I tried doing this, but this too did not work for speaking to a nested component.

How can a parent component cause a method on the nested component to fire?

Thank you
Hello,

I'm creating a visual workflow and trying to add a dynamic dropdown. Through a loop that looks up records in one field based on parameters passed in the URL, I've saved the values into a collection variable. But I'm having trouble using that collection as my dropdown choices.

Looking at the three choice options:

Choice - Doesn't take collections at all
Dynamic Record Choice - Looks up on a sObj. The problem with this is, my list has pulled from multiple sObj
Picklist Choice - Same as Dynamic Record choice; looks up to a single sObj.

All I want to be able to do is to create a list of choices from a collection. Is this not possible?

Thank you!
I'm creating a visual workflow which will guide a user through creating different sObjs. Depending on user input from a previous page, I'd like to show/hide future fields.

Example:
 
Screen 1 
--------- 
Display: Would you like Beer or Juice? 
Input Field: Dropdown 

Screen 2 
-------- 
Display: Select a type 
Input field: Dynamic Dropwdown 
(If beverage.type == 'Beer') 
Display: Please enter your age 
Input: Integer Box

On screen 2, there is no need to show the age integer box if the beverage type is juice. What I would like to be able to do is be able to show/hide fields based on certain boolean vars (i.e. Boolean Beverage_is_alcohol).

This is a simplistic example. The use case has multiple screens with sufficiently more "show/hide" fields that it would make the form page significantly longer.

I haven't seen anything in the Visual Flow documents that show a standard way to accomplish this. I have two thoughts on how I might solve this - but before choosing either, I'd like to ask for ideas.

Option 1 - Multiple Screen Options

Create several screens with different field combinations. Create Decision Nodes to route user to the screen with the correct combination of fields.

*This may require we create an exponentially growing amount of screens. This option is likely not scalable.

Option 2 - jQuery Dom Manipulation

Find a way to signal JS which field set should be shown and find fields via element.id and hide them (or remove, considering that hiding doesn't shrink the form size)

*This option requires a developer be made available for changes. I'd prefer if non-technical users can make changes to the workflow.

Is there an option 3? If not, perhaps you can offer some advice about which of the above two is the better path?

Thank you!
I'm trying to create a visual force page with a table and a "request" button that will take the selected row and append it as a task.

Here's a photo of the table:
User-added image

When a user hits request, I want to create a task that includes the deal name and deal owner.

Here is the VF page:
<apex:page controller="A7_OppsCntrl" standardStylesheets="false" sidebar="false">   

    <apex:form>
        <table id= 'a7Table' class='display'>
            <thead>
                <tr>
                    <th>Deal Name</th>
                    <th>Deal Owner</th>
                    <th>Request</th>
                </tr>
            </thead>
           <apex:repeat value="{!A7Opps}" var="row">
               <tr>
                   <apex:repeat value="{!A7Opps[row]}" var="cell">
                       <td> {!cell} </td>
                   </apex:repeat>
                   <td>
                       <apex:commandButton action="{!send2Admin}" value="Request" title="Send Request to Admin" oncomplete="" reRender="block">
                           <apex:param value="{!A7Opps[row]}" assignTo="{!paramValue}"/>
                       </apex:commandButton>
                   </td>
               </tr>
           </apex:repeat>
         </table>
    </apex:form>
</apex:page>

Here is the controller:
 
Global With Sharing class A7_OppsCntrl {

    static string paramValue;

    public static void send2Admin(){

        user adminId = [SELECT id from user where name like 'Sir Admin' limit 1];
        string userId = toolbox.grabUserId(); //Grabs context user ID
        user userName = [SELECT name from user where id = :userId];

        task leadReq = new task();
        leadReq.OwnerId = adminId.id;
        leadReq.Subject = 'New Request';
        leadReq.Description = userName.name+' is requesting '+paramValue;
        insert(leadReq);
    }

The task is successfully inserted, but the paramValue comes up as null.

What am I doing incorrectly (probably a lot ;)? How can I get the row data to be appended to the description of the task?

I've tried following https://developer.salesforce.com/forums/ForumsMain?id=906F000000095uXIAQ

Didn't help.

Thanks!
I've developed an apex API on salesforce which performs a SOQL on a list of CSV data. It has been working smoothly until yesterday, after making a few changes to code that follow the SOQL query, I started getting a strange 500 error:
 
[{"errorCode":"APEX_ERROR","message":"System.UnexpectedException: common.exception.SfdcSqlException: ORA-01460: unimplemented or unreasonable conversion requested\n\n\nselect /SampledPrequery/ sum(term0) \"cnt0\",\nsum(term1) \"cnt1\",\ncount(*) \"totalcount\",\nsum(term0 * term1) \"combined\"\nfrom (select /*+ ordered use_nl(t_c1) /\n(case when (t_c1.deleted = '0') then 1 else 0 end) term0,\n(case when (upper(t_c1.val18) = ?) then 1 else 0 end) term1\nfrom (select /+ index(sampleTab AKENTITY_SAMPLE) */\nentity_id\nfrom core.entity_sample sampleTab\nwhere organization_id = '00Dq0000000AMfz'\nand key_prefix = ?\nand rownum <= ?) sampleTab,\ncore.custom_entity_data t_c1\nwhere t_c1.organization_id = '00Dq0000000AMfz'\nand t_c1.key_prefix = ?\nand sampleTab.entity_id = t_c1.custom_entity_data_id)\n\nClass.labFlows.queryContacts: line 13, column 1\nClass.labFlows.fhaQuery: line 6, column 1\nClass.zAPI.doPost: line 10, column 1"}]

the zAPI.doPost() is simply our router class which takes in the post payload as well as the requested operation. It then calls whatever function the operation requests. In this case, the call is to labFlows.queryContacts():
Public static Map<string,List<string>> queryContacts(string[] stringArray){

//First get the id to get to the associative entity, Contact_Deals__c id
List<Contact_Deals__c> dealQuery = [SELECT id, Deal__r.id, Deal__r.FHA_Number__c, Deal__r.Name, Deal__r.Owner.Name
                                 FROM Contact_Deals__c
                                 Where Deal__r.FHA_Number__c in :stringArray];

//Using the id in the associative entity, grab the contact information
List<Contact_Deals__c> contactQuery = [Select Contact__r.Name, Contact__r.Id, Contact__r.Owner.Name, Contact__r.Owner.Id, Contact__r.Rule_Class__c, Contact__r.Primary_Borrower_Y_N__c
                   FROM contact_deals__c
                   WHERE Id in :dealQuery];
//Grab all deal id's
Map<string,List<string>> result = new Map<string,List<string>>();
for(Contact_Deals__c i:dealQuery){
    List<string> temp = new list<string>();
    temp.add(i.Deal__r.Id);
    temp.add(i.Deal__r.Owner.Name);
    temp.add(i.Deal__r.FHA_Number__c);
    temp.add(i.Deal__r.Name);
    for(Contact_Deals__c j:contactQuery){
        if(j.id == i.id){
            //This doesn't really help if there are multiple primary borrowers on a deal - but that should be a SF worflow rule IMO
            if(j.Contact__r.Primary_Borrower_Y_N__c == 'Yes'){
                temp.add(j.Contact__r.Owner.Id);
                temp.add(j.Contact__r.Id);
                temp.add(j.Contact__r.Name);
                temp.add(j.Contact__r.Owner.Name);
                temp.add(j.Contact__r.Rule_Class__c);
                break;
            }
        }               
    }
    result.put(i.Deal__r.id, temp); 
}
return result;
}

The only thing I've changed is moving the temp list to add elements before the inner-loop (previously temp would only capture things from the inner-loop). The error above is referencing line 13, which is specifically the first SOQL call:
 
List<Contact_Deals__c> dealQuery = [SELECT id, Deal__r.id, Deal__r.FHA_Number__c, Deal__r.Name, Deal__r.Owner.Name
                                         FROM Contact_Deals__c
                                         Where Deal__r.FHA_Number__c in :stringArray];

I've tested this function in the apex anonymous window and it worked perfectly:
 
string a = '00035398,00035401'; 
string result = zAPI.doPost(a, 'fhaQuery'); 
system.debug(result);

Results:
 
13:36:54:947 USER_DEBUG [5]|DEBUG|{"a09d000000HRvBAD":["a09d000000HRvBAD","Contacta","11111111","Plaza Center Apts"],"a09d000000HsVAD":["a09d000000HsVAD","Contactb","22222222","The Garden"]}

So this is working. The next part is maybe looking at my python script that is calling the API,
 
def origQuery(file_name, operation):
    csv_text = ""
    with open(file_name) as csvfile:
        reader = csv.reader(csvfile, dialect='excel')
        for row in reader:
            csv_text += row[0]+','
            csv_text = csv_text[:-1]

    data = json.dumps({
        'data' : csv_text,
        'operation' : operation
    })


    results = requests.post(url, headers=headers, data=data) 
    print results.text

origQuery('myfile.csv', 'fhaQuery')

I've tried looking up this ORA-01460 apex error, but I can't find anything that will help me fix this issue.

Can any one shed ore light on what this error is telling me?

Thank you all so much!
Hello,

After querying for Account sObjects, I'm adding all the fields into a List. The problem is that some Account sObjects have certain fields and others do not. While adding the fields to my list, I'd like to be able to add field if it exists OR add a default string.

Let's go through the example.
 
My query:List<Account> accountQuery = [SELECT name, (SELECT name, id FROM Contacts) FROM Account];

My map:
Map<String, List<String>> Result = new Map<String, List<String>>();

Iterating through the queryResult and saving the values:
For(Account i : accountQuery){ 
    String[] temp = new list<string>(); 
    temp.add(i.name) 
    //Now loop through contacts subquery 
    if(!i.contacts.isEmpty()){ 
        for(contact j : i.Contacts){ 
            temp.add(j.name || 'No Contact Name Associated'); //Doesn't work   
            temp.add(j.id || 'No Contact Id Associated'); 
        } 
    } 
    else{ 
        temp.add('No Contact Name Associated'); 
        temp.add('No Contact Id Associated'); 
    } 
};

How can I achieve this temp.add(value || 'default value')?

Thank you!
Hello,

I'm having issues communicating to a nested component. I would like a component to be able to run a method in the nested-component's controller.js (or helper). I have tried both events and via and no luck. Here is the example markup:
 
<!-- myEvent.evt --> 
<aura:event type="APPLICATION"> 
</aura:event> 

<!-- super-component --> 
<aura:component>
    <aura:registerEvent name="myEventName" type="c:myEvent"/> 
    <c:my_Nested_Component /> 
    <ui:button press="{!fireEvent}" 
<aura:component> 

//super-component_controller.js 
({ 
    fireEvent: function(component){ 
        var myEvent = component.getEvent("myEventName"); 
        myEvent.fire(); 
        console.log('event fired'); 
    } 
}) 

------------------------------------------ 

<!-- nested-component --> 
<aura:component> 
    <aura:handler name="myEventName" event="c:c:myEvent" action="{!c.gotEvent}" /> 
<aura:component> 

//nested-component_controller.js 
({ 
    gotEvent: function(component, event){ 
        console.log('received event!'); 
    } 
})

This does not work. I tried the same exact code that I placed on the nested-component on a super-super-component, and it worked perfectly.The super-super component received the event. But the nested component is not able to. I figured this had to do with events only bubbling up (though the documentation does say that that is only the case with Component events, not application events).

So the other option I read online is using . I tried doing this, but this too did not work for speaking to a nested component.

How can a parent component cause a method on the nested component to fire?

Thank you
I'm trying to create a visual force page with a table and a "request" button that will take the selected row and append it as a task.

Here's a photo of the table:
User-added image

When a user hits request, I want to create a task that includes the deal name and deal owner.

Here is the VF page:
<apex:page controller="A7_OppsCntrl" standardStylesheets="false" sidebar="false">   

    <apex:form>
        <table id= 'a7Table' class='display'>
            <thead>
                <tr>
                    <th>Deal Name</th>
                    <th>Deal Owner</th>
                    <th>Request</th>
                </tr>
            </thead>
           <apex:repeat value="{!A7Opps}" var="row">
               <tr>
                   <apex:repeat value="{!A7Opps[row]}" var="cell">
                       <td> {!cell} </td>
                   </apex:repeat>
                   <td>
                       <apex:commandButton action="{!send2Admin}" value="Request" title="Send Request to Admin" oncomplete="" reRender="block">
                           <apex:param value="{!A7Opps[row]}" assignTo="{!paramValue}"/>
                       </apex:commandButton>
                   </td>
               </tr>
           </apex:repeat>
         </table>
    </apex:form>
</apex:page>

Here is the controller:
 
Global With Sharing class A7_OppsCntrl {

    static string paramValue;

    public static void send2Admin(){

        user adminId = [SELECT id from user where name like 'Sir Admin' limit 1];
        string userId = toolbox.grabUserId(); //Grabs context user ID
        user userName = [SELECT name from user where id = :userId];

        task leadReq = new task();
        leadReq.OwnerId = adminId.id;
        leadReq.Subject = 'New Request';
        leadReq.Description = userName.name+' is requesting '+paramValue;
        insert(leadReq);
    }

The task is successfully inserted, but the paramValue comes up as null.

What am I doing incorrectly (probably a lot ;)? How can I get the row data to be appended to the description of the task?

I've tried following https://developer.salesforce.com/forums/ForumsMain?id=906F000000095uXIAQ

Didn't help.

Thanks!
I've developed an apex API on salesforce which performs a SOQL on a list of CSV data. It has been working smoothly until yesterday, after making a few changes to code that follow the SOQL query, I started getting a strange 500 error:
 
[{"errorCode":"APEX_ERROR","message":"System.UnexpectedException: common.exception.SfdcSqlException: ORA-01460: unimplemented or unreasonable conversion requested\n\n\nselect /SampledPrequery/ sum(term0) \"cnt0\",\nsum(term1) \"cnt1\",\ncount(*) \"totalcount\",\nsum(term0 * term1) \"combined\"\nfrom (select /*+ ordered use_nl(t_c1) /\n(case when (t_c1.deleted = '0') then 1 else 0 end) term0,\n(case when (upper(t_c1.val18) = ?) then 1 else 0 end) term1\nfrom (select /+ index(sampleTab AKENTITY_SAMPLE) */\nentity_id\nfrom core.entity_sample sampleTab\nwhere organization_id = '00Dq0000000AMfz'\nand key_prefix = ?\nand rownum <= ?) sampleTab,\ncore.custom_entity_data t_c1\nwhere t_c1.organization_id = '00Dq0000000AMfz'\nand t_c1.key_prefix = ?\nand sampleTab.entity_id = t_c1.custom_entity_data_id)\n\nClass.labFlows.queryContacts: line 13, column 1\nClass.labFlows.fhaQuery: line 6, column 1\nClass.zAPI.doPost: line 10, column 1"}]

the zAPI.doPost() is simply our router class which takes in the post payload as well as the requested operation. It then calls whatever function the operation requests. In this case, the call is to labFlows.queryContacts():
Public static Map<string,List<string>> queryContacts(string[] stringArray){

//First get the id to get to the associative entity, Contact_Deals__c id
List<Contact_Deals__c> dealQuery = [SELECT id, Deal__r.id, Deal__r.FHA_Number__c, Deal__r.Name, Deal__r.Owner.Name
                                 FROM Contact_Deals__c
                                 Where Deal__r.FHA_Number__c in :stringArray];

//Using the id in the associative entity, grab the contact information
List<Contact_Deals__c> contactQuery = [Select Contact__r.Name, Contact__r.Id, Contact__r.Owner.Name, Contact__r.Owner.Id, Contact__r.Rule_Class__c, Contact__r.Primary_Borrower_Y_N__c
                   FROM contact_deals__c
                   WHERE Id in :dealQuery];
//Grab all deal id's
Map<string,List<string>> result = new Map<string,List<string>>();
for(Contact_Deals__c i:dealQuery){
    List<string> temp = new list<string>();
    temp.add(i.Deal__r.Id);
    temp.add(i.Deal__r.Owner.Name);
    temp.add(i.Deal__r.FHA_Number__c);
    temp.add(i.Deal__r.Name);
    for(Contact_Deals__c j:contactQuery){
        if(j.id == i.id){
            //This doesn't really help if there are multiple primary borrowers on a deal - but that should be a SF worflow rule IMO
            if(j.Contact__r.Primary_Borrower_Y_N__c == 'Yes'){
                temp.add(j.Contact__r.Owner.Id);
                temp.add(j.Contact__r.Id);
                temp.add(j.Contact__r.Name);
                temp.add(j.Contact__r.Owner.Name);
                temp.add(j.Contact__r.Rule_Class__c);
                break;
            }
        }               
    }
    result.put(i.Deal__r.id, temp); 
}
return result;
}

The only thing I've changed is moving the temp list to add elements before the inner-loop (previously temp would only capture things from the inner-loop). The error above is referencing line 13, which is specifically the first SOQL call:
 
List<Contact_Deals__c> dealQuery = [SELECT id, Deal__r.id, Deal__r.FHA_Number__c, Deal__r.Name, Deal__r.Owner.Name
                                         FROM Contact_Deals__c
                                         Where Deal__r.FHA_Number__c in :stringArray];

I've tested this function in the apex anonymous window and it worked perfectly:
 
string a = '00035398,00035401'; 
string result = zAPI.doPost(a, 'fhaQuery'); 
system.debug(result);

Results:
 
13:36:54:947 USER_DEBUG [5]|DEBUG|{"a09d000000HRvBAD":["a09d000000HRvBAD","Contacta","11111111","Plaza Center Apts"],"a09d000000HsVAD":["a09d000000HsVAD","Contactb","22222222","The Garden"]}

So this is working. The next part is maybe looking at my python script that is calling the API,
 
def origQuery(file_name, operation):
    csv_text = ""
    with open(file_name) as csvfile:
        reader = csv.reader(csvfile, dialect='excel')
        for row in reader:
            csv_text += row[0]+','
            csv_text = csv_text[:-1]

    data = json.dumps({
        'data' : csv_text,
        'operation' : operation
    })


    results = requests.post(url, headers=headers, data=data) 
    print results.text

origQuery('myfile.csv', 'fhaQuery')

I've tried looking up this ORA-01460 apex error, but I can't find anything that will help me fix this issue.

Can any one shed ore light on what this error is telling me?

Thank you all so much!
Hello,

After querying for Account sObjects, I'm adding all the fields into a List. The problem is that some Account sObjects have certain fields and others do not. While adding the fields to my list, I'd like to be able to add field if it exists OR add a default string.

Let's go through the example.
 
My query:List<Account> accountQuery = [SELECT name, (SELECT name, id FROM Contacts) FROM Account];

My map:
Map<String, List<String>> Result = new Map<String, List<String>>();

Iterating through the queryResult and saving the values:
For(Account i : accountQuery){ 
    String[] temp = new list<string>(); 
    temp.add(i.name) 
    //Now loop through contacts subquery 
    if(!i.contacts.isEmpty()){ 
        for(contact j : i.Contacts){ 
            temp.add(j.name || 'No Contact Name Associated'); //Doesn't work   
            temp.add(j.id || 'No Contact Id Associated'); 
        } 
    } 
    else{ 
        temp.add('No Contact Name Associated'); 
        temp.add('No Contact Id Associated'); 
    } 
};

How can I achieve this temp.add(value || 'default value')?

Thank you!