• Puja Patil 13
  • NEWBIE
  • 80 Points
  • Member since 2016
  • Salesforce Developer
  • Aress Software & Education Technologies (P) Ltd., Pune


  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 17
    Replies
How to remove suffix and Middle name in Compound Name Field in Contact and Account..?
HI all,


How to increase the character size of custom field (LongTextArea)...?
By default it's charactor limit is 131072 characters (128 kB). I want to save more charactors in same field.

Please let me know If anyone have the solution for this problem..

Thanks in Advanced,
Puja
Hi,
I have Trigger on Order Line Item. I also wrote test class for that but it can not covers "trigger.isDelete" and  "Trigger.isUpdate" cases.
Please check following trigger and test class : 

//********************************* Trigger *************************************
trigger TotalPiecesSum on OrderItem (before update, before insert,before delete) {

list<Order> a = new list<Order>();
    set<id> OrderIDs= new set<id>();

if(trigger.isInsert || trigger.isBefore){
   for(OrderItem o : Trigger.new){
      OrderIDs.add(o.Orderid);
   }
   }

else if(trigger.isDelete){
     for(OrderItem o : Trigger.old){
         OrderIDs.add(o.Orderid);
     }
}
else 
      
     if(Trigger.isUpdate){
        for(OrderItem  o : Trigger.new){
             if(OrderItem.OrderId != null && o.Pieces__c!= trigger.oldMap.get(o.Id).Pieces__c){
                OrderIDs.add(o.OrderId);
             }      
         }
     }
    
    update a;
    
    AggregateResult[] groupedResults = [SELECT SUM(Pieces__c),OrderId FROM OrderItem where OrderId IN :OrderIDs GROUP BY OrderId ];
    system.debug('*******groupedResults **********'+groupedResults);     
    
    for(AggregateResult ar:groupedResults) {
        Id orid = (ID)ar.get('OrderId');
        system.debug('*******selected Oredr id **********'+orid);     
        Decimal count = (Decimal)ar.get('expr0');
            
        Order o1 = new Order(Id=orid);
        o1.Total_Pieces1__c= count;
        system.debug('*******Total_Pieces1__cOredr id **********'+count); 
        a.add(o1);
       }
   update a;
 
}

​//********************************* Test Class*************************************


@isTest(seeAllData = true)
private class TestTotalPiecesSum {
 
    static testMethod void myUnitTest() {
    
    //Test Account Insert

    Account a = new Account();
    a.Name = 'Test Account';
    a.Custom2__c = '000093';
    a.Business_Type__c = 'Consultant';
    insert a;

    Product2 p = new Product2();
    p.Name = ' Test Product ';
    p.Description='Test Product Entry 1';
    p.productCode = 'ABC';
    p.isActive = true;
    insert p;
    
    

    Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where IsStandard = true limit 1];
    
    PricebookEntry standardPrice = new PricebookEntry();
    standardPrice.Pricebook2Id = standardPb.Id;
    standardPrice.Product2Id = p.Id;
    standardPrice.UnitPrice = 1;
    standardPrice.IsActive = true;
    standardPrice.UseStandardPrice = false;
    insert standardPrice ;
    
    //Test Order Insert
    
    Order o = new Order();
    o.Name = 'Test Order ';
    o.Status = 'Draft';
    o.EffectiveDate = system.today();
    o.EndDate = system.today() + 4;
    o.AccountId = a.id;
    o.Pricebook2Id =  standardPb.Id ;
    
    insert o;
    system.assertEquals(o.Total_Pieces1__c, null);
    
    OrderItem i = new OrderItem();
    i.OrderId = o.id;
    i.Quantity = 24;
    i.UnitPrice = 240;
    i.Pieces__c = i.Quantity;
    i.Product2id = p.id;
    i.PricebookEntryId=standardPrice.id;
    //i.Total_Price__c = i.Quantity * i.UnitPrice;
    insert i;


    Order or1 = [SELECT Total_Pieces1__c from Order where Id = :o.Id];
    system.assertEquals(or1.Total_Pieces1__c ,i.Pieces__c);


    //Test OrderItem on update

    OrderItem op1 = [select Pieces__c,PricebookEntryId from OrderItem where Id = :i.Id];
    op1.Pieces__c = 24;
    update op1;
 
    Order or2 = [SELECT Total_Pieces1__c from Order where Id = :o.Id];
    system.assertEquals(or2.Total_Pieces1__c ,op1.Pieces__c);

    //Test OrderItem on second insert
 
    OrderItem i2 = new OrderItem();
    i2.OrderId = o.id;
    i2.Quantity = 24;
    i2.UnitPrice = 240;
    i2.Pieces__c = i.Quantity;
    i2.PricebookEntryId=standardPrice.id;
    //i2.Total_Price__c = i.Quantity * i.UnitPrice;
    insert i2;
    
    AggregateResult ag1 = [select sum(Pieces__c) from OrderItem where OrderId = :o.Id];
 
    Order o3 = [select Total_Pieces1__c from Order where Id = :o.Id];
    system.assertEquals(o3.Total_Pieces1__c,ag1.get('expr0'));
 
    AggregateResult ag2 = [select sum(Pieces__c) from OrderItem where OrderId = :o.Id];
 
    Order o4 = [select Total_Pieces1__c from Order where Id = :o.Id];
    system.assertEquals(o4.Total_Pieces1__c,ag1.get('expr0'));  
 
    }  
}

It gives 66% Code Coverage.
 
Hi all,
 I want to create new field dynamically , I have written following apex class.
But it gives erroe as " Invalid type: MetadataService.MetadataPort "

public class CustomField1 {
    String sessionID = UserInfo.getSessionId();
    public static void createField()
    {
        MetadataService.MetadataPort service = createService();     
        MetadataService.CustomField customField = new            MetadataService.CustomField();
        customField.fullName = 'Account.TestField__c';
        customField.label = 'Test Field';
        customField.type_x = 'Text';
        customField.length = 42;
        List<MetadataService.SaveResult> results =    service.createMetadata(
                new MetadataService.Metadata[] { customField });                
        handleSaveResults(results[0]);
    }
}

If anyone knows..Please help me..
Hi,
I have to change the datatype of "Releted To" field of "Task" object.
i.e. What id of task. This is lookup field. and i want only 3 objects i.e. Account, Contact, Opportunity.
Hi,
I have following After Update Trigger... I have to write test class for same...
Please some one help me..?

trigger AccountChanged on Asset (after update) {

    List<Opportunity> OppList= new List<Opportunity>();
   
    for (Asset newAsset : Trigger.new) {

                                        // If account of equipment is changed..
        if ( newAsset.AccountId != Trigger.oldMap.get( newAsset.Id ).AccountId ){    
            
                                        //Create new Opportunity for Sales i.e. OEM Record Type...
            Opportunity newOpp1 = new Opportunity();
            
            Id oppRecordTypeId1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OEM').getRecordTypeId();
            newOpp1.RecordTypeId = oppRecordTypeId1;
            
            
            newOpp1.Asset__c = newAsset.id;
            newOpp1.Name = 'New Sales Opportunity';
            newOpp1.AccountId = newAsset.AccountId;
            newOpp1.StageName = 'Qualification';
            newOpp1.CloseDate = system.today();
            

            OppList.add(newOpp1);
            
          
                                            //Create new Opportunity for Parts i.e. Parts Record Type...
            Opportunity newOpp2 = new Opportunity();
            
            Id oppRecordTypeId2 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Parts').getRecordTypeId();
            newOpp2.RecordTypeId = oppRecordTypeId2;
            
            
            newOpp2.Asset__c = newAsset.id;
            newOpp2.Name = 'New Parts Opportunity';
            newOpp2.AccountId = newAsset.AccountId;
            newOpp2.StageName = 'Qualification';
            newOpp2.CloseDate = system.today();
            

            OppList.add(newOpp2);
            
            If(OppList.Size()>0){
            Insert OppList;
            }
        }

    }
}
I have 3 objects Leap , Test , Student.
Leap - Parent Object
Test - Child of Leap
Student - Child of Test

I want trigger when Leap is created new test and student also create.
I have to import more than 1500 records in custom object by using dataloader.io , but following error occures in importing :
ERROR: icad.ICADNCPASort: System.LimitException: Apex CPU time limit exceeded
and by using import wizard
ERROR : System.LimitException: icad:Too many DML statements:151
but there is no any trigger or class in org and no any DML estatment used.
 
How to implement Drag n Drop functionality for div section in VFPage ..?
Hi,
Good Morning.
can any one help me to solve the following.........
I have an object student__c. It has only one field name.i would like to add the records into object using VF page. Initiallay, In VF page I have Add button,Save button & a text box. When i click on add button i need to display one more textbox. Like this i can add any number of textboxes. But when i entered data into these textboxes and clicked on save. I would like to add all the names into object in the form of records. That means, each name will be added into object as a record. i need controller class also Can any one help me.
Can we change the data type of BillingCounrty field (text to picklist) of Billing address in Contact Object..?
 
Hi, 

I have to write the Test class for following function : 

Public PageReference doInsert(){
    questID = ApexPages.currentPage().getParameters().get('id');
    system.debug('++++++++++++++++QUEST ID++++++++++++++++++'+questID);
    //fdID = fdmain;
    List<Feedback_Option_Main__c> optionlist=new List<Feedback_Option_Main__c>();
    
    Feedback_Question_Main__c fqmobj=new Feedback_Question_Main__c();
    Feedback_Option_Main__c fom = new Feedback_Option_Main__c();
    fqmobj.Question__c=questiontaken;
    fqmobj.Related_Feedback__c=questID;
    fqmobj.Type__c='Radio';
    insert fqmobj;
    fom.Option_One__c = OptionOneGet;
    fom.Option_Two__c = OptionTwoGet;
   fom.Option_Three__c = OptionThreeGet;
    fom.Option_Four__c = OptionFourGet;            
    fom.Option_Five__c = OptionFiveGet;    
    fom.Related_Question__c = fqmobj.id;
    optionlist.add(fom);
    
    insert optionlist;
    
    String msg = 'Question added successfully !';
    ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, msg));
    
    PageReference ref=new PageReference('/apex/SBDemoMain?id=questID');
    ref.setredirect(false);
    return ref;
    }


 
I have to print the info or data of account object and related contact info of that account on visualforce page... how can i do that...?
 
Can we change the data type of BillingCounrty field (text to picklist) of Billing address in Contact Object..?
 
HI all,


How to increase the character size of custom field (LongTextArea)...?
By default it's charactor limit is 131072 characters (128 kB). I want to save more charactors in same field.

Please let me know If anyone have the solution for this problem..

Thanks in Advanced,
Puja
Hi,
I have following After Update Trigger... I have to write test class for same...
Please some one help me..?

trigger AccountChanged on Asset (after update) {

    List<Opportunity> OppList= new List<Opportunity>();
   
    for (Asset newAsset : Trigger.new) {

                                        // If account of equipment is changed..
        if ( newAsset.AccountId != Trigger.oldMap.get( newAsset.Id ).AccountId ){    
            
                                        //Create new Opportunity for Sales i.e. OEM Record Type...
            Opportunity newOpp1 = new Opportunity();
            
            Id oppRecordTypeId1 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('OEM').getRecordTypeId();
            newOpp1.RecordTypeId = oppRecordTypeId1;
            
            
            newOpp1.Asset__c = newAsset.id;
            newOpp1.Name = 'New Sales Opportunity';
            newOpp1.AccountId = newAsset.AccountId;
            newOpp1.StageName = 'Qualification';
            newOpp1.CloseDate = system.today();
            

            OppList.add(newOpp1);
            
          
                                            //Create new Opportunity for Parts i.e. Parts Record Type...
            Opportunity newOpp2 = new Opportunity();
            
            Id oppRecordTypeId2 = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Parts').getRecordTypeId();
            newOpp2.RecordTypeId = oppRecordTypeId2;
            
            
            newOpp2.Asset__c = newAsset.id;
            newOpp2.Name = 'New Parts Opportunity';
            newOpp2.AccountId = newAsset.AccountId;
            newOpp2.StageName = 'Qualification';
            newOpp2.CloseDate = system.today();
            

            OppList.add(newOpp2);
            
            If(OppList.Size()>0){
            Insert OppList;
            }
        }

    }
}
I have 3 objects Leap , Test , Student.
Leap - Parent Object
Test - Child of Leap
Student - Child of Test

I want trigger when Leap is created new test and student also create.
How to implement Drag n Drop functionality for div section in VFPage ..?
Hi,
Good Morning.
can any one help me to solve the following.........
I have an object student__c. It has only one field name.i would like to add the records into object using VF page. Initiallay, In VF page I have Add button,Save button & a text box. When i click on add button i need to display one more textbox. Like this i can add any number of textboxes. But when i entered data into these textboxes and clicked on save. I would like to add all the names into object in the form of records. That means, each name will be added into object as a record. i need controller class also Can any one help me.
How to remove suffix and Middle name in Compound Name Field in Contact and Account..?
Hi,

How to display the custom object records to customer community plus user created by customer community user.And i have build the hiearachy relation between customer comunity user and customer community plus user in contacts using 'Reports To' lookup.Please find the below screen shot for reference.


User-added image


 
Hi, 

I have to write the Test class for following function : 

Public PageReference doInsert(){
    questID = ApexPages.currentPage().getParameters().get('id');
    system.debug('++++++++++++++++QUEST ID++++++++++++++++++'+questID);
    //fdID = fdmain;
    List<Feedback_Option_Main__c> optionlist=new List<Feedback_Option_Main__c>();
    
    Feedback_Question_Main__c fqmobj=new Feedback_Question_Main__c();
    Feedback_Option_Main__c fom = new Feedback_Option_Main__c();
    fqmobj.Question__c=questiontaken;
    fqmobj.Related_Feedback__c=questID;
    fqmobj.Type__c='Radio';
    insert fqmobj;
    fom.Option_One__c = OptionOneGet;
    fom.Option_Two__c = OptionTwoGet;
   fom.Option_Three__c = OptionThreeGet;
    fom.Option_Four__c = OptionFourGet;            
    fom.Option_Five__c = OptionFiveGet;    
    fom.Related_Question__c = fqmobj.id;
    optionlist.add(fom);
    
    insert optionlist;
    
    String msg = 'Question added successfully !';
    ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, msg));
    
    PageReference ref=new PageReference('/apex/SBDemoMain?id=questID');
    ref.setredirect(false);
    return ref;
    }


 
I have to print the info or data of account object and related contact info of that account on visualforce page... how can i do that...?
 

 

Hi,

    i am using following code when i used it means it showing  an error message connection lost please check your connection, actually i created a my system admin as live agent when he login also it showing an error can any one help me.


MY CODE:::::::::

<html>
<head>
<title>
My title
</title>

<script type='text/javascript' src='https://c.la2c1.salesforceliveagent.com/content/g/deployment.js'></script>
</head>
<body>
Welcome to Live Agent

<a id="liveagent_button_online_573E0000000Ccuh" href="javascript&colon;//Chat" style="display: block;" onclick="liveagent.startChat('573E0000000Ccuh')"> Start live agent</a>

<script type='text/javascript'>
liveagent.init('https://d.la2c1.salesforceliveagent.com/chat', '572i0000000Qr3I', '00Di0000000d7eN');
</script>
<img id="liveagent_button_online_573i0000000Qskn" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('573i0000000Qskn')" src="https://esoftcenter-developer-edition.na15.force.com/resource/1377010559000/onlineimage" /><img id="liveagent_button_offline_573i0000000Qskn" style="display: none; border: 0px none; " src="https://esoftcenter-developer-edition.na15.force.com/resource/1377010588000/offlineimage" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573i0000000Qskn', document.getElementById('liveagent_button_online_573i0000000Qskn'));
liveagent.showWhenOffline('573i0000000Qskn', document.getElementById('liveagent_button_offline_573i0000000Qskn'));
});</script>

</body>
</html>

Hi All,

 

I am new to Saleforce development. Please can any one guide me to sample apex code to create(add) custom fields to custom or standard objects dynamically using Salesforce Metadata API in my development org.

 

Thanks in advance.

  • June 29, 2011
  • Like
  • 0