• ANITHA BEEMU
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 1
    Replies
This is the apex class:
public class CAMRelatedCases 
{
    private final Account acct;
    public CAMRelatedCases(ApexPages.StandardController setCon) 
    {
        this.acct = (Account)setCon.getRecord();
    }
    public List<Case> getmyCaseList()
    {
        myCaseList = [SELECT ID,CaseNumber, CreatedDate, Subject, AccountID, OwnerID, Account.Name, Owner.Name FROM Case WHERE Account.Dealer_of_Record__c = :this.acct.Id];
        Return myCaseList;
    }
    List<Case> myCaseList = [SELECT ID, CaseNumber, AccountID, OwnerID, CreatedDate, Subject, Description, Account.Name, Owner.Name FROM Case LIMIT 4999];
}


and i wrote test class as follows:

@isTest(seealldata = true)
public class CAMRelatedCasesTest 
{
    Static testMethod void CAMRelatedCases()
    {
        //Creating the account for testing
        account a1 = new account(name = 'test'); 
        Insert a1;
        //Creating the Contact w/email
        contact con = new contact(lastname ='testing', firstname = 'testcontact',email='testingit@gmail.com', accountid = a1.Id);
        
        Case cs = new Case(Account = a1, RecordTypeID = '012500000005eVdAAI', Status = 'Open', Origin = 'Inbound Phone Call', Subject = 'testing for apex class', 
                           Description = 'this needs to be a long description', Update_RMA_Task__c = False);
        Insert cs;
        
        CAMRelatedCases.getmyCaseList();
      }
}


Getting Error:Non static method cannot be referenced from a static context: List<Case> CAMRelatedCases.getmyCaseList()

Please can anyone help..
Hi,Can any one help in validation rule or any way to sort this on the following:
in an object we have fields A,B,C,D,E, all are lookup fields which are related to same parent object ,when a record got inserted into the object.
like A           B            C                 D                  E

prod A     prod B     Prod c      prodD                                 have to insert 
Prod A    Prod B                                                           should not insert
Prod A                   Prod E                                            Should not insert
Prod A     Prod F                                                             Have to insert
Prod A     Prod F   Prod G                                            Should not insert

Prod A  A field can have multiple Records with B field same r value of B is not allowed and once Prod A Record have C,D,E values again should inert values of same record..
Please can anyone help on this ..Thank you.
Hi can anyone help on validation Rule:i have a field sales order number which is text,i want that field to be numeric  and when an RMA_outcome value is picked as credit only,sales order number cannot be Null:

i tired following,its not working..any help pls:
AND(OR(ISBLANK(Sales_Order_Number__c),
NOT(REGEX( Sales_Order_Number__c,"^[a-z A-Z]*$")))
&&

ISPICKVAL(  RMA_Outcome__c , "Credit Only") &&
ISBLANK( Sales_Order_Number__c )
)
Hi,i have created a lightning components,where for one field i want a link to open to the record detail page..

my components:
<aura:component controller="WP_dRMA_SubProducts" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="gridColumns" type="List"/>
    <aura:attribute name="gridData" type="Object"/>
    <aura:attribute name="sku" type="string"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <lightning:accordion aura:id="accordion" activeSectionName="B">
        <lightning:accordionSection name="B" label="Sub Components">
            <lightning:treeGrid aura:id="subProdTreegridID" 
                                columns="{!v.gridColumns }"
                                data="{!v.gridData }"                               
                                keyField="KeyField"
             />
        </lightning:accordionSection>
    </lightning:accordion>
    
</aura:component>
my controller:
({
    doInit : function(cmp, event, helper){
        cmp.set('v.gridColumns',[
            {label:'Product Name', fieldName:'productName', type:'text'},
            {label:'Product Code', fieldName:'productCode',  type: 'url',
            typeAttributes: {label: { fieldName: 'productCode' },value:{fieldName: 'productCode'}, target: '_blank'}
               },            
        ]);
            
        helper.getSubProducts(cmp, event);            
    },
    
})
my helper:

({
    getSubProducts : function(cmp, event) {
        var skuVal = cmp.get('v.sku');
        var action = cmp.get('c.getRelatedProducts');
        action.setParams({sku:skuVal});
        action.setCallback(this,function(response){
            var state = response.getState();
            console.log('**state-->'+state);
            if(state === "SUCCESS"){
                var data = response.getReturnValue();
              // data.forEach(function(data){
                  //  data.productCode = '/'+data.Id;
               // });
                console.log('**data-->'+data);
                //JSON.parse(response.getReturnValue());                        
                //var temojson = JSON.parse(JSON.stringify(data).split('items').join('_children'));
                //console.log('**temojson-->'+temojson);
                for(var i=0;i<data.length;i++){
                    data[i]._children = data[i]['items'];
                    delete data[i].items;
                }
                console.log('**data after changing to _children-->'+data);
                cmp.set('v.gridData',data);
                //cmp.set('v.gridData',temojson);
                console.log('**gridData-->'+cmp.get('v.gridData'));
            }else if(state === "ERROR"){
                var errors = action.getError();
                if(errors){
                    if(errors[0] && errors[0].message){
                        console.log('**error Message-->'+errors[0].message);
                    }
                }
            }
        });            
        $A.enqueueAction(action);  
    }    
})
Hi can anyone help on this..i created a lightning component to show in tree grid format all the parents and related childs and their related childs and vice versa...bin log its showing but in UI, its not showing.. any help please

here is my component:

<aura:component controller="Test_SubProductsUser-added image" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="gridColumns" type="List"/>
    <aura:attribute name="gridData" type="Object"/>
    <aura:attribute name="sku" type="string"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <!--<lightning:accordion aura:id="accordion" activeSectionName="B">
        <lightning:accordionSection name="B" label="Sub Components">-->
            <lightning:treeGrid aura:id="subProdTreegridID" 
                                columns="{!v.gridColumns }"
                                data="{!v.gridData }"                               
                                keyField="KeyField"
             />
        <!--</lightning:accordionSection>
    </lightning:accordion>-->
    
</aura:component>


my controller:

({
    doInit : function(cmp, event, helper){
        cmp.set('v.gridColumns',[
            {label:'Product Name', fieldName:'productName', type:'text'},
            {label:'Product Code', fieldName:'productCode', type:'text'},            
        ]);
        var skuVal = cmp.get('v.sku');
        var action = cmp.get('c.getRelatedProducts');
        action.setParams({sku:skuVal});
        action.setCallback(this,function(response){
            var state = response.getState();
            console.log('**state-->'+state);
            if(state === "SUCCESS"){
                var data = response.getReturnValue();
                console.log('**data-->'+data);
                JSON.parse(response.getReturnValue());                        
                var temojson = JSON.parse(JSON.stringify(data).split('items').join('_children'));
                console.log('**temojson-->'+temojson);
                cmp.set('v.gridData',temojson);
                console.log('**gridData-->'+cmp.get('v.gridData'));
            }
        });
    $A.enqueueAction(action);
    } 
})


my Apex code:

public class Test_SubProducts {    
    static map<Id,list<Id>> productIdsMap = new map<Id,list<Id>>();
    static list<Id> parentProductIds;
    static list<Id> childProductIds;
    
    //get the products in Tree.
    @AuraEnabled
    public static string getRelatedProducts(string sku){        
        list<Product_Relationships__c> prodRelaList = new list<Product_Relationships__c>();
        list<Id> produIds;
        map<Id,Product2> productMap;
        
        prodRelaList = [Select Parent_Sku__c,Child_Sku__c from Product_Relationships__c where Parent_Sku__r.ProductCode =: sku];
               
        return JSON.serializePretty(getHeirarchy(prodRelaList));
    }
    
    static list<Product_Relationships__c> getProductRelationShip(list<Id> productIds){
        return [Select Parent_Sku__c,Child_Sku__c from Product_Relationships__c where Parent_Sku__c IN: productIds];
    }
    
    //get the parent and child products ids
    static void getProductIds(list<Product_Relationships__c> prodRelaList){
        if(prodRelaList != null && !prodRelaList.isEmpty()){
            productIdsMap = new map<Id,list<Id>>();
            parentProductIds = new list<Id>();
            childProductIds = new list<Id>();
                       
            for(Product_Relationships__c prodRela: prodRelaList){
                if(prodRela.Parent_Sku__c != null){
                    parentProductIds.add(prodRela.Parent_Sku__c);
                    if(prodRela.Child_Sku__c != null){
                        childProductIds.add(prodRela.Child_Sku__c);                        
                        if(productIdsMap.containsKey(prodRela.Parent_Sku__c)){
                            productIdsMap.get(prodRela.Parent_Sku__c).add(prodRela.Child_Sku__c);
                        }else{
                            productIdsMap.put(prodRela.Parent_Sku__c,new list<Id>{prodRela.Child_Sku__c});
                        }                        
                    }                    
                }                    
            }//end of for
        }        
    }
    
    static map<Id,Product2> getProducts(set<Id> productsIds){
        return new Map<Id,Product2>([Select Id, Name, ProductCode, Description from Product2 where ID IN: productsIds]);
    }
            
    static list<ProductsWrapper> getHeirarchy(List<Product_Relationships__c> topProds){
        list<ProductsWrapper> prodWrapList = new list<ProductsWrapper>();
        
        if(topProds != null && !topProds.isEmpty()){
            getProductIds(topProds);
            
            if(parentProductIds != null && !parentProductIds.isEmpty()){
                set<Id> productIds = new set<Id>();
                productIds.addAll(parentProductIds);
                if(childProductIds != null && !childProductIds.isEmpty()){                    
                    productIds.addAll(childProductIds);
                }//end of if childproductids check.
                
                map<Id,Product2> prodMap = new map<Id,Product2>();
                prodMap = getProducts(productIds);
                for(Id prodId: parentProductIds){
                    ProductsWrapper prodWrapInst = new ProductsWrapper();
                    prodWrapInst.keyField = prodId;
                    prodWrapInst.productName = prodMap.get(prodId).Name;
                    prodWrapInst.productCode = prodMap.get(prodId).ProductCode;
                    list<Items> level1Prods = new list<Items>();
                    if(productIdsMap.containsKey(prodId) && productIdsMap.get(prodId) != null){
                        for(Id childProdId: productIdsMap.get(prodId)){
                            Items level1Child = new Items();
                            level1Child.keyField = childProdId;
                            level1Child.productName = prodMap.get(childProdId).Name;
                            level1Child.productCode = prodMap.get(childProdId).ProductCode;
                            
                            level1Prods.add(level1Child);
                        }
                        
                    }//end of if prodidmap check.
                    prodWrapInst.items = level1Prods;
                    prodWrapList.add(prodWrapInst);
                }//end of for parentids.                
            }//end of if parentproductids check.
        }//end of if topproduts check.
        
        return prodWrapList;
    }
           
    //Wrapper Class for Parent Products and Child Products.
    public Class ProductsWrapper{
        @AuraEnabled
        public String KeyField {get;set;}
        @AuraEnabled
        public String productName {get;set;}
        @AuraEnabled
        public String productCode {get;set;}
        @AuraEnabled
        public List<Items> items {get;set;}
    }
    
    //Wrapper Class for Child Products and Child Products.
    public Class Items{
        @AuraEnabled
        public String KeyField {get;set;}
        @AuraEnabled
        public String productName {get;set;}
        @AuraEnabled
        public String productCode {get;set;}
        
    }

}
HI can anyone help in validation rule,i have two checkbox fields A and B and 1 picklist field C,now i need to write a validation rule if A and B are checked (or) true,the value in field c cant be edited..i tried using this:

AND(
Field A = TRUE,
Field B = TRUE ,
OR(

ISPICKVAL(Field C ,'Purchaser')
)
)

but when i am edit field A its throwing validation error cant edit..can any one help.
Hi can any one help for writing a test class for ths:

public class LoanDocumentGenrate{

    private final LLC_BI__Loan__c ln;    
   

    public LoanDocumentGenrate(ApexPages.StandardController stdController) {
        
                this.ln = (LLC_BI__Loan__c)stdController.getRecord(); 

    }

    public PageReference pgclose() {
            
        PageReference pgref = new PageReference('/' + ln.Id);
        pgref.setRedirect(true);
        return pgref;  
    }


}
Hi ,

i have a small issue,i created a approval process in which i used an email template,now when approval process go to an approver,i need to make approve can click on the link to direct him to record page.i used detail link,it will show link details,but it will direct him to record data .i want on click to direct .can anyone please help..
This is the apex class:
public class CAMRelatedCases 
{
    private final Account acct;
    public CAMRelatedCases(ApexPages.StandardController setCon) 
    {
        this.acct = (Account)setCon.getRecord();
    }
    public List<Case> getmyCaseList()
    {
        myCaseList = [SELECT ID,CaseNumber, CreatedDate, Subject, AccountID, OwnerID, Account.Name, Owner.Name FROM Case WHERE Account.Dealer_of_Record__c = :this.acct.Id];
        Return myCaseList;
    }
    List<Case> myCaseList = [SELECT ID, CaseNumber, AccountID, OwnerID, CreatedDate, Subject, Description, Account.Name, Owner.Name FROM Case LIMIT 4999];
}


and i wrote test class as follows:

@isTest(seealldata = true)
public class CAMRelatedCasesTest 
{
    Static testMethod void CAMRelatedCases()
    {
        //Creating the account for testing
        account a1 = new account(name = 'test'); 
        Insert a1;
        //Creating the Contact w/email
        contact con = new contact(lastname ='testing', firstname = 'testcontact',email='testingit@gmail.com', accountid = a1.Id);
        
        Case cs = new Case(Account = a1, RecordTypeID = '012500000005eVdAAI', Status = 'Open', Origin = 'Inbound Phone Call', Subject = 'testing for apex class', 
                           Description = 'this needs to be a long description', Update_RMA_Task__c = False);
        Insert cs;
        
        CAMRelatedCases.getmyCaseList();
      }
}


Getting Error:Non static method cannot be referenced from a static context: List<Case> CAMRelatedCases.getmyCaseList()

Please can anyone help..