• Shreya Salesforce
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 0
    Replies
"customer" : [ {
    "Type" : "Prospect",
    "SFDCAccountId" : "0016F000034Noh8QAC",
    "Phone" : "855245286896",
    "Name" : "acc3",
    "Email" : "test@test.com"
  }, null ],
Hii...I am new in Salesforce.
In project, Apptus package is installed. And I am not able to see Apex class because of managed package. 
My requirement is - On Invoice object, there is a credit memo button. On click this button, we create a credit memo in Salesforce and integrates with credit Memo in Netsuite.
There are also some validations on Visualforce page. i am not able to create credit memo in Salesforce and also not to see Apex class.
What should i have to do??
I make Acc1(child object)and Acc2(child object) whose parent is 'Acc3'. My trigger shows only '1'in field 'Total_No_of_Child_Accounts__c'.
Please help me to solve this problem.

trigger TotalChildAccounts on Account (after insert,after Update,after delete,after Undelete) 
{
    //List<Account> childaccIds= new List<Account>();
    //List<Id> ParentaccIds= new List<Id>();
    Map<Id,Account> accMap= new Map<Id,Account>();
    if(trigger.isInsert || trigger.isUpdate || trigger.isUndelete)
    {
        for(Account acc:trigger.new)
        {
            if(acc.ParentId!=null)
            {
                accMap.put(acc.ParentId,acc);
                //childaccIds.add(acc);
                //ParentaccIds.add(acc.ParentId);
                // System.debug('childaccIds=='+childaccIds);
                // System.debug('ParentaccIds=='+ParentaccIds);
            }
        }
    }
    if(trigger.isDelete)
    {
        for(Account acc:trigger.old)
        {
            if(acc.ParentId!=null)
            {
                accMap.put(acc.ParentId,acc);
            }
        }
    }
    List<Account> FetchParentAccList = [SELECT Id,Name,Total_No_of_Child_Accounts__c,ParentId FROM Account WHERE ParentId IN:accMap.keyset()];
    List<Account> accList = new List<Account>();
        For(Account achild : FetchParentAccList)
        {
            if(accMap.containskey(achild.Id))
            {
                achild.Total_No_of_Child_Accounts__c = FetchParentAccList.size();
                accList.add(achild);
            }
            
            
        }
        if(accList.size()>0)
        {
        Update acclist;
        }
}
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 collect the data in the list<Test_object__c> through OpportunityLineItem Id.  One List is coming and list size will be 1. Another List is coming, again list size is 0. But I want to store every List and store it into 'TestObjectJson' class. How it is possible??
List<Test_object__c> testList =[SELECT Id,Name,Product__c,Product__r.Name,Opportunity__c,Value1__c,Value2__c,Value3__c,OpportunityLineItemId_del__c FROM Test_object__c WHERE OpportunityLineItemId_del__c =:oid]; 
                List<Test_object__c> finaltestList= new List<Test_object__c>();
                System.debug('testObject List==' +testList);
                System.debug('testList == ' +testList.size()); 
                
                if(testList.size()>0)
                {   
                    oobj.testobject= new TestObjectJson[testList.size()];
                    for(Integer b=0;b<testList.size();b++)
                    {
                    //Test_object__c tobj = testList[0];
                    //System.debug('tname : '+tobj.Name); 
                    finaltestList.add(testList[b]);
                    System.debug('finaltestList == ' +finaltestList.size()); 
                    
                    Test_object__c tobj = testList[b];
                    TestObjectJson t = new TestObjectJson();
                    t.Name = tobj.Name;            
                    System.debug('t.Name : '+t.Name);
                    t.Product = tobj.Product__c;
                    System.debug('t.Product : '+t.Product);
                    t.ProductName = tobj.Product__r.Name;
                    System.debug('t.ProductName :' +t.ProductName);
                    t.Value1 = tobj.Value1__c;
                    System.debug('t.Value1 : '+t.Value1);
                    t.Value2 = tobj.Value2__c;
                    System.debug('t.Value2 : '+t.Value2);
                    t.Value3 = tobj.Value3__c;
                    System.debug('t.Value3 : '+t.Value3);
                    oobj.testobject[b] = t;
                    }
                } 
for(Integer i=0;i<lstdlt.size();i++){
lstw.add(new wrapper(lsttest[i].name,lsttest[i].city__c,lstdlt[i].country__c,lstdlt[i].phone__c));
}
 
link is:  https://www.salesforcetutorial.com/wrapper-class-wrapper-class-example/
public with sharing class Account_manager{
    public Contact placeholderContact{get;set;}
    public List<Contact> accountContacts{get;set;}
    
    public Account_manager(){
    placeholderContact= new Contact();
    accountContacts= new List<Contact>();
    }
}