You need to sign in to do that
Don't have an account?
Priya Ravichandran
apex class developement
Hi,
I want to create a apex class with the below input an output.. am new to SF please help.
Input
=====
Field1|Field2
AAA|1,2
BBB|1,2,3
CCC|1,2,3,4
DDD|1,2,3,4,5
Output
======
AAA|1
AAA|2
BBB|1
BBB|2
BBB|3
CCC|1
CCC|2
CCC|3
CCC|4
DDD|1
DDD|2
DDD|3
DDD|4
DDD|5
I want to create a apex class with the below input an output.. am new to SF please help.
Input
=====
Field1|Field2
AAA|1,2
BBB|1,2,3
CCC|1,2,3,4
DDD|1,2,3,4,5
Output
======
AAA|1
AAA|2
BBB|1
BBB|2
BBB|3
CCC|1
CCC|2
CCC|3
CCC|4
DDD|1
DDD|2
DDD|3
DDD|4
DDD|5
Below is the code. I understood your requirement as if we enter AAA in field 1 and 3 in field 2 the result should be AAA1, AAA2, AAA3. Marks this as the best answer if it helps.
Create an apex class like this
Run this in Anonymous window
The result will be like below.
I have an custom object with the fields as column A, columnB , Column C, Column D and their values are A, B,Product1, product 2 in the format as below.
Input :
Column A Column B Column C Column D
A B Product1 Product2
C D Product3
Output wil be
Column A Column B Column C
A B Product1
A B Product2
C D Product3
I have to create an Apex class with the custom objects and fields like this. Please adivse.
So, in a custom object you have record like ColumnA - A Columnb - b columnc- product1 columnd- product2. If it is like this then you wanted to removed the columnd’s Value and create a new record by putting the values in columnc with same value as columna and columnb. Is t right?
Yuvaraj
I have created a small Apex class.
Public class Products
{
LIST <API__c>lst;
LIST <API__c> test1;
LIST <API__c> test2;
LIST <API__c> test3;
List<SObject> CombinedItems=new List<SObject>();
Public LIST <API__c> getAccount()
{
try
{
lst=[SELECT Name__c, Phone__c, Product_1__c,Product_2__c from API__c limit 10];
for(API__c ValueFile : lst)
{
if(ValueFile.Product_1__c!=null)
{
test1=[SELECT Name__c, Phone__c, Product_1__c from API__c limit 10];
}
if(ValueFile.Product_2__c!=null)
{
test2=[SELECT Name__c, Phone__c, Product_2__c from API__c WHERE Product_2__c != '" "' AND Product_2__c != null LIMIT 5];
}
}
CombinedItems.addAll(test1);
CombinedItems.addAll(test2);
return CombinedItems;
}
catch(Exception ex)
{
System.debug('Error'+ex.getMessage());
}
return CombinedItems;
}
}
how to display the final value which is in "CombinedItems" List into the VF page into the column name as Name, Phone & Product. Appreciate your help.