• Vamsi Vaddipalli
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hi,
I have one scenario - Whenever new child get inserted existing child records get update for the same Parent.
Parent:STD__c
Child:Attended__c.
Trigger:
trigger IsLatestAtt on Attended__c (after insert) {
    IsLatestAttClass.met(Trigger.new);
}
Class Code:
public class IsLatestAttClass {
    public static void met(List<Attended__c> att)
    {
Set<id> ids = new Set<id>();
        
        for(Attended__c obj:att)
        {
            ids.add(obj.STD_lookup__c);
            obj.IsFirst_Contact__c = true;
        }
 List<Attended__c>  abb =   [SELECT Name,IsFirst_Contact__c,STD_lookup__r.Name FROM Attended__c WHERE Attended__c.STD_lookup__c IN: ids];
       List<Attended__c> attlist = new List<Attended__c>();
       List<Attended__c> attlistnew = new List<Attended__c>();
        for(Attended__c obj:abb)
        {
            if(obj.IsFirst_Contact__c == true)
            {
                obj.IsFirst_Contact__c = false;
                attlist.add(obj);
                //Trigger.new.add(obj);
            }

        }
        update attlist;
    }

}
Error: When i try to update existing child records it is throwing error. (IsLatestAtt: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.IsLatestAttClass.met: line 9, column 1 Trigger.IsLatestAtt: line 2, column 1)
Please can anyone help...!
Hi,
I am doing J2S Trailmix2 module Salesforce mobile App Customization - Compact Layout.
I am getting below error :
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: CJNQNWGT.

Please help me...! Thanks in Advance
Hi,
This is Vamsi need one help friends
I wrote a trigger to upadte parent record while child got created. But it is not working can yoy guide me.

trigger InTri on APEX_Invoice__c (after insert) {

List<APEX_Invoice__c> inn = new List<APEX_Invoice__c>();
List<APEX_Customer__c> cuu = new List<APEX_Customer__c>();
    List<APEX_Customer__c> cus = new List<APEX_Customer__c>();
    List<ID> ids = new List<ID>();
    for(APEX_Invoice__c obj1:Trigger.new)
    {
        ids.add(obj1.APEX_Customer__r.id);
    }
cuu = [SELECT id,Name,APEX_Customer_Status__c FROM APEX_Customer__c WHERE ID IN: ids];
for(APEX_Customer__c obj:cuu)
{
obj.APEX_Customer_Status__c = 'Paid';
   cus.add(obj); 
}
 update cus; 
}
Hi,
i am new to salesforce i want to creat an visualforce page  to display pageblocksection on selecting a value from the picklist using rendered.
But when i am selecting Energy value in pickList it is not showing NoofEmployees field.

Can you people please guide me

visualforce:
<apex:page standardController="Account" extensions="HidePageBlock">
    <apex:form >
    <apex:pageBlock title="Industry">
        <apex:pageBlockSection title="Options">
            <apex:inputField value="{!Account.Industry}"/>
            <actionsupport event='onchange' rerender='in1'/>
            
        </apex:pageBlockSection>
            
                    <apex:pageBlockSection title="Result" id="in1" rendered="{!IF(Account.Industry == 'Energy',true,false)}">
                        <apex:inputField value="{!Account.NumberOfEmployees}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
        </apex:form>
</apex:page>


Contoller Extension:
public class HidePageBlock {
    public HidePageBlock(ApexPages.StandardController controller)
    {
        
    }

}

Thanks and Regards
Hi,
I have one scenario - Whenever new child get inserted existing child records get update for the same Parent.
Parent:STD__c
Child:Attended__c.
Trigger:
trigger IsLatestAtt on Attended__c (after insert) {
    IsLatestAttClass.met(Trigger.new);
}
Class Code:
public class IsLatestAttClass {
    public static void met(List<Attended__c> att)
    {
Set<id> ids = new Set<id>();
        
        for(Attended__c obj:att)
        {
            ids.add(obj.STD_lookup__c);
            obj.IsFirst_Contact__c = true;
        }
 List<Attended__c>  abb =   [SELECT Name,IsFirst_Contact__c,STD_lookup__r.Name FROM Attended__c WHERE Attended__c.STD_lookup__c IN: ids];
       List<Attended__c> attlist = new List<Attended__c>();
       List<Attended__c> attlistnew = new List<Attended__c>();
        for(Attended__c obj:abb)
        {
            if(obj.IsFirst_Contact__c == true)
            {
                obj.IsFirst_Contact__c = false;
                attlist.add(obj);
                //Trigger.new.add(obj);
            }

        }
        update attlist;
    }

}
Error: When i try to update existing child records it is throwing error. (IsLatestAtt: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.IsLatestAttClass.met: line 9, column 1 Trigger.IsLatestAtt: line 2, column 1)
Please can anyone help...!