• Gulshan Raj 4
  • NEWBIE
  • 95 Points
  • Member since 2016

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
APEX CLASS:

public class fetch1 {
    public list<account> acc{set;get;}
    public map<string,list<contact>> mp{set;get;}
    public fetch1(){
        acc=[select name,(select lastname,firstname from contacts) from account ];
        list<contact> con=new list<contact>();
        mp=new map<string,list<contact>>();
        for(account a:acc){
            for(contact c:a.contacts){
                con.add(c);
                 }
            mp.put(a.name,con);
        }
        }
        }

VF:

<apex:page controller="fetch1" >
    <apex:form >
    <apex:pageBlock >
       <apex:pageBlockTable value="{!acc}" var="a">
        <apex:column headerValue="ACCOUNTS" value="{!a.name}"/>
           <apex:column headerValue="RELATED CONTACTS" >
               <apex:pageBlockTable value="{!mp}" var="cont">
               <apex:column value="{!mp[cont].firstname}"/>
                   <apex:column value="{!mp[cont].lastname}"/>
               </apex:pageBlockTable>
           </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

ERROR:
There are no errors in code.But when i am going for a preview of vf page i am getting this error "Incorrect parameter type for subscript. Expected Number, received Text "

 
I'm working with cloud flow designer and having some issues with the Apex class callout. I know I will need to return a List<List<CustomSobject>> from the invocable method in order to process the collection. But I am stuck overcomplicating the code in order to get what I would normally use a List for into the right format to return. I probably need an additional for loop but am not sure of the format. If I only return a List<CustomSobject> the Flow will not be able to process it as a collection returning multiple records. Below is my method, this current version compiles but the flow will throw an "List index out of bounds" error. Nor is it correct, as I want all the elements returned not just the first. Thanks in advance.
@InvocableMethod(label = 'Services Available')
public static List<List<Create_Product__c>> getServices(List<Address__c> addressInput){
    //created to hold return list of lists
    List<List<Create_Product__c>> wrapper = new List<List<Create_Product__c>>();

    //The data set to be returned
    List<Create_Product__c> productsAvailable = [SELECT Product_Code__c, Starting_Price__c FROM Create_Product__c];

    for (Create_Product__c products: productsAvailable ){
        List<Create_Product__c> responseList = new List<Create_Product__c>();

        responseList[0].Product_Code__c = products.Product_Code__c;
        responseList[0].Starting_Price__c = products.Starting_Price__c;

        wrapper.add(responseList);
    }

    return wrapper;
}

 
I have a custom object "Service Agreement". I need a button on the opportunity page to create a new "Service Agreement". This seems like it should be pretty simple, but I am not having any success (possibly due to my lack of experience with coding).
APEX CLASS:

public class fetch1 {
    public list<account> acc{set;get;}
    public map<string,list<contact>> mp{set;get;}
    public fetch1(){
        acc=[select name,(select lastname,firstname from contacts) from account ];
        list<contact> con=new list<contact>();
        mp=new map<string,list<contact>>();
        for(account a:acc){
            for(contact c:a.contacts){
                con.add(c);
                 }
            mp.put(a.name,con);
        }
        }
        }

VF:

<apex:page controller="fetch1" >
    <apex:form >
    <apex:pageBlock >
       <apex:pageBlockTable value="{!acc}" var="a">
        <apex:column headerValue="ACCOUNTS" value="{!a.name}"/>
           <apex:column headerValue="RELATED CONTACTS" >
               <apex:pageBlockTable value="{!mp}" var="cont">
               <apex:column value="{!mp[cont].firstname}"/>
                   <apex:column value="{!mp[cont].lastname}"/>
               </apex:pageBlockTable>
           </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

ERROR:
There are no errors in code.But when i am going for a preview of vf page i am getting this error "Incorrect parameter type for subscript. Expected Number, received Text "

 
I'm working with cloud flow designer and having some issues with the Apex class callout. I know I will need to return a List<List<CustomSobject>> from the invocable method in order to process the collection. But I am stuck overcomplicating the code in order to get what I would normally use a List for into the right format to return. I probably need an additional for loop but am not sure of the format. If I only return a List<CustomSobject> the Flow will not be able to process it as a collection returning multiple records. Below is my method, this current version compiles but the flow will throw an "List index out of bounds" error. Nor is it correct, as I want all the elements returned not just the first. Thanks in advance.
@InvocableMethod(label = 'Services Available')
public static List<List<Create_Product__c>> getServices(List<Address__c> addressInput){
    //created to hold return list of lists
    List<List<Create_Product__c>> wrapper = new List<List<Create_Product__c>>();

    //The data set to be returned
    List<Create_Product__c> productsAvailable = [SELECT Product_Code__c, Starting_Price__c FROM Create_Product__c];

    for (Create_Product__c products: productsAvailable ){
        List<Create_Product__c> responseList = new List<Create_Product__c>();

        responseList[0].Product_Code__c = products.Product_Code__c;
        responseList[0].Starting_Price__c = products.Starting_Price__c;

        wrapper.add(responseList);
    }

    return wrapper;
}

 
I have a custom object "Service Agreement". I need a button on the opportunity page to create a new "Service Agreement". This seems like it should be pretty simple, but I am not having any success (possibly due to my lack of experience with coding).
Hi All,

I was writing a sample code on Nested List. 
public class NestedListDemo {
    List<String> toDoList  = new List<String>{'laundry','shopping'};
    List<String> laundryList = new List<String>{'lights','darks'};
    List<String> groceryList = new List<String>{'fruits','vegetables'};
    List<List<String>> completeList = new List<List<String>>();
    completeList.add(toDoList);
    completeList.add(laundryList);
    completeList.add(groceryList);
    System.debug('Contents of toDoList'+toDoList);
    System.debug('Contents of groceryList'+groceryList);
    System.debug('Contents of laundryList'+laundryList);
    System.debug('Contents of completeList'+completeList);
    System.debug('Contents of First Element in completeList'+completeList[1]);

}

I am getting error in line 9. Error "Error: Compile Error: unexpected token: ')' at line 9 column 29".
any help would be appreciated.
Thanks in Advance