You need to sign in to do that
Don't have an account?
Shreya Salesforce
How i can show list data into a custom field of object??
Hii...I am new in Salesforce.Please help me to solve this.
I have a custom field 'NS_ID__c'(Text) on Product and Error_Message__c(Text Area) is custom field on Opportunity. These products are in OpportunityLineItem.
My requirement is if NS_ID__c is blank then these Product Names show on 'Error_Message__c' on Opportunity.
I get a list 'proid' which contains product Names...but i stuck, how to show this list in 'Error_Message__c' field.
List<string> proid = new List<string>();
Map<Id,List<String>> prodMap= new Map<Id,List<String>>();
List<Product2> prodList= [SELECT Id,Name,NS_ID__c FROM Product2 WHERE Id=:o.Product2Id];
if(prodList.size() > 0)
{
Product2 prd = prodList[0];
string pnsid = prd.NS_ID__c;
System.debug('pnsid : '+pnsid);
if(pnsid == null)
{
proid.add(prd.Name);
System.debug('final product List : '+proid);
string allstring = string.join(proid,',');
for(Product2 pro: prodList)
{
prodMap.put(o.OpportunityId,proid);
System.debug('prodMap==' +prodMap);
}
prodMap.get(Id).Error_Message__c = allstring;
update prodMap.values();
}
}
I have a custom field 'NS_ID__c'(Text) on Product and Error_Message__c(Text Area) is custom field on Opportunity. These products are in OpportunityLineItem.
My requirement is if NS_ID__c is blank then these Product Names show on 'Error_Message__c' on Opportunity.
I get a list 'proid' which contains product Names...but i stuck, how to show this list in 'Error_Message__c' field.
List<string> proid = new List<string>();
Map<Id,List<String>> prodMap= new Map<Id,List<String>>();
List<Product2> prodList= [SELECT Id,Name,NS_ID__c FROM Product2 WHERE Id=:o.Product2Id];
if(prodList.size() > 0)
{
Product2 prd = prodList[0];
string pnsid = prd.NS_ID__c;
System.debug('pnsid : '+pnsid);
if(pnsid == null)
{
proid.add(prd.Name);
System.debug('final product List : '+proid);
string allstring = string.join(proid,',');
for(Product2 pro: prodList)
{
prodMap.put(o.OpportunityId,proid);
System.debug('prodMap==' +prodMap);
}
prodMap.get(Id).Error_Message__c = allstring;
update prodMap.values();
}
}
Can you replace below last two lines
with below updated lines
Let us know if you face any issues.
Best Regards,
BALAJI