• Pankaj Chauhan 11
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies

Hi guys,

I have 2 custom objects (Management and ReportsandDashboards)
I have a field name flat section in management .So i have to count total no. of flat records created in management  by creating a field in 
ReportsandDashboards

I've tried creating a formula field, but not it's not clear to me what the formula should be.
I also tried creating an Apex trigger. However, I couldn't get the select statement to work.

I want a field in ReportsandDashboards that is readonly and counts the number of time the field flat is used in the Management .

Please advice the correct way to approach this :)
I have the similar requirement with Contract as an parent object with building section in it as a custom field which has a lookup relationship with custom object named Management.I want to autopopulate the field of Building section in contract object through the field of building section in management object.

i have write the code with the help of yours but it is not working.Kindly Help

trigger Management on Management__c (before insert, before update) {

    Set<id>ids=new set<id>();
list<contract>oplst=new list<contract>();
    For(Management__c b:trigger.new){
        if(b.Building_Section__c!=Null){
            ids.add(b.Building_Section__c); //lookup field to opportunity on bid__c
        }
    }
    if(!ids.Isempty()){
        list<contract >opp=[select id,name from contract where Building_Section__c=Null AND id in:ids];
        for(contract op:opp){
         
            for(Management__c bd: trigger.new){
                op.Building_Section__c=bd.id;
                oplst.add(op);
            }
        }
        update oplst;
    }   
}
How to Achieve this using lightning Component
Show 2 buttons in cutom tab Contact Details, Create Contact and Update Contact.
On click of Update contact, all the details of existing contact (associated with case) should be displayed.
Change city / country of contact and save successfully.
If create new contact is clicked then get all the details, validate them and save contact and associated with case as Secondary Contact (create contact lookup field on Case).
Hi,

I'm new to developing in general and I am trying to create a trigger that updates the custom lookup field Bid_Name__c on the standard Opportunity object. I have a created a custom object called Bid__c which has a related one-to-one relationship with the Opportunity. I'm getting an error when attempting to save the Opportunity record, although it mentions the correct reference below but doesnt populate the field. My code is pasted below the error message.

System.StringException: Invalid id: Bid-1312: Trigger.UpdateBid: line 9, column 1

trigger UpdateBid on Opportunity (before insert, before update) {
    if (trigger.isBefore) { 
        if (trigger.isInsert || trigger.isUpdate) {
            //list Bids
            list<Bid__c> Bid = [SELECT ID, Name FROM Bid__c];
            for (Opportunity o : trigger.new) {
                o.Bid_Name__c = null;
                for (Bid__c b : Bid){
                    if (b.Name == o.Bid_Name__c) {
                        o.Bid_Name__c = b.Name;
                        break;
                    }
                }
            }
        }
    }
}

Any help that could be offered would be appreciated, struggling to work out what the solution here is.

Thank you