• Soundar Raj Ponpandi
  • NEWBIE
  • 180 Points
  • Member since 2017
  • Salesforce Developer

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 39
    Questions
  • 58
    Replies
Hello all,

We would like to change the subject ""First payment reminder" " as mentioned in below sample visulaforce code, based on the some condtions.
That means, If i send first reminder email then i am going to update the field "Total remider sent" value to 1,
Then later after checking other due dates conditions, ww would like to send another email but with different Subject i.e ". "Second payment reminder" and again update Total remider sent" value to 2.
can you please help how to handle such situation, This will help me to reuse same template for all the reminder;s, Invoice information will be picked up on run time, so no issues with that.


My Visualforce working code is - 

<messaging:emailTemplate subject="First payment reminder" recipientType="Contact" relatedToType="Account">

<!-- <messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody> -->

<messaging:htmlEmailBody >
    <STYLE type="text/css">
        TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
        TD  {font-size: 11px; font-face: verdana }
        TABLE {border: solid #CCCCCC; border-width: 1}
        TR {border: solid #CCCCCC; border-width: 1}
     </STYLE>
     <font face="arial" size="2">

<font size="2" face="Lucida Sans Unicode" > Dear  {!relatedTo.Name}, </font><br/>
<br/>

<font size="2" face="Lucida Sans Unicode" >Our financial records show that -- subscription for the total amount {!relatedTo.CurrencyIsoCode}&nbsp;{!relatedTo.Total_Outstanding_Amount__c} </font><br/>
<br/>


 
<br/>
        <table border="0" > 
            <tr>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Invoice Number   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Payment Due Date   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Amount Due   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Currency   ;</font><br/></th>
                
            </tr>
            
            <apex:repeat var="cx" value="{!relatedTo.Invoices__r}" >

               <tr>
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >{!cx.Invoice_Number__c}&nbsp;</font></td>
                        
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >
                            <apex:outputText value="{0,date,dd'/'MMM'/'yyyy}">
                                <apex:param value="{!cx.Transaction_Due_Date_del__c}" /> 
                            </apex:outputText>&nbsp;</font>
                        </td>


                        <td align="right"><font size="2" face="Lucida Sans Unicode">&nbsp;
                            <apex:outputText style="float:right" value="{0, number, ###,##0.00}">
                                <apex:param value="{!cx.Outstanding_Amount_FC__c}"/>
                            </apex:outputText>&nbsp;</font>
                        </td>
                        
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >{!cx.Currency__c}&nbsp;</font></td>
                                                                        
               </tr>
                                   
            </apex:repeat>
        </table>  
     </font>
                    
<br/>

<font size="2" face="Lucida Sans Unicode" >Our bank details:</font><br/>
<font size="2" face="Lucida Sans Unicode" >Payment reference: {!relatedTo.Exact_Online_Account_ID__c} </font><br/>
<font size="2" face="Lucida Sans Unicode" >Please do not hesitate to contact us with questions. Thank you in advance for your cooperation. </font><br/>

<br/>
<br/>
<br/>  
                
<font size="2" face="Lucida Sans Unicode" >Best regards,</font><br/>
<font size="2" face="Lucida Sans Unicode" >Collection department</font><br/>
<font size="2" face="Lucida Sans Unicode" >BV Amsterdam, the Netherlands</font><br/>
                
</messaging:htmlEmailBody>
</messaging:emailTemplate>

Dears,

I created a form by using lightning component.

1. I need to allow a submitters to upload 60 sec video OR allow a submitters upload from system / Phone.

2. Is that possible ?

3. If Yes, Can you please provide a sample code Or Explainantion ?

Regards,

Soundar.

Dear's,
I am trying to complete this Challange in trailhead, But i am facing this issue even i added a "accDisplay" and "accEdit" in lighting page.

Can you please give me a good suggestion to complete this challange in trailhead !!
 
Error : 

Could not find either the 'accEdit' component, 'accDisplay' component or both components in the Account Record Page.



Regards,
Soundar.
Dears,

I can't add a field in work order report "Service Report language", Even it's added into report type layout.

Can anyone advise me how can i enable it's in report.

Regards,
Soundar.
Hi,

I am facing following Error while run a test class. 

Error : 
Methods defined as TestMethod do not support Web service callouts


Test Class : 
 
@isTest
public class AccountProcessorTest {
    
    @isTest
    public static void testFunc() {
        account acc = new account();
        acc.name = 'MATW INC';
        insert acc;
        
        contact con = new contact();
        con.lastname = 'Mann1';
        con.AccountId = acc.Id;
        con.email = '123@gmail.com';
        insert con;
        contact con1 = new contact();
        con1.lastname = 'Mann2';
        con1.AccountId = acc.Id;
        con.email = '124@gmail.com';
        insert con1;
        
        
        List<Id> acc_list = new List<Id>();
        acc_list.add(acc.Id);
        Test.startTest();
            AccountProcessor.countContacts(acc_list);
        Test.stopTest();
        List<account> acc1 = new List<account>([select Number_of_Contacts__c from account where id = :acc.id]);
        system.assertEquals(2,acc1[0].Number_of_Contacts__c);
    }

}

Note : Facing this error while cover a test class for @future Method 
 
public class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> accountId_lst) {
        
        Map<Id,Integer> account_cno = new Map<Id,Integer>(); 
        List<account> account_lst_all = new List<account>([select id, (select id from contacts) from account]);
        for(account a:account_lst_all) {
            account_cno.put(a.id,a.contacts.size()); //populate the map
            
        }
                    
        List<account> account_lst = new List<account>(); // list of account that we will upsert
            
        for(Id accountId : accountId_lst) {
            if(account_cno.containsKey(accountId)) {
                account acc = new account();
                acc.Id = accountId;
                acc.Number_of_Contacts__c = account_cno.get(accountId);
                account_lst.add(acc);
            }
            
        }
        upsert account_lst;
    }

}


Regards,
Soundar.
Dears,

How to create acustom  report type for account/opportunity/Campaign ? Is that possible ?

Can anyone give me a valid suggestion, How can i achieve this.

Regards,
Soundar.
Dear Developers,

I faced following Error while save RMA Object (RMA__C).
 
insufficient access rights on cross-reference id: 01u2400000HB1iU

01u2400000HB1iU - PriceBook Entry Id

Thanks in Advance !! 


Regards,
Soundar Rajan P.
 
Dears,

1. I changed lookup to picklist in vf page
2. Selected picklist value is not saved in corresponding field.

Can anyone please advise ??

@controller
Public Class lookuptoPick{
Public String AddressId{Get;Set;}

public list<selectOption> getPickAccountVals(){
            list<selectOption> options  = New List<selectOption>();
            options.add(new selectOption('' , '-- None --'));
            for(Clinical_Address_Association__c claddr: [Select id,name from Clinical_Address_Association__c]){
                options.add(new selectoption(claddr.id,claddr.name));
            }
            system.debug('Options |' + options);
        return options;
    }
 Public void save(){
  // Insert Object Here 
 }

}


@VF PAge
<apex:pageBlockSectionItem dataStyle="width:1%" labelStyle="width:1%" >
   <apex:outputLabel >Address Id</apex:outputLabel>
    <apex:selectList size="1" value="{!AddressId}" label="Address ID" multiselect="false" style="width:180px">
         <apex:selectOptions value="{!PickAccountVals}" ></apex:selectOptions>
    </apex:selectList>
</apex:pageBlockSectionItem>

1. Getting AddressId by {Get;set;}
2. Then how can i save this object.

Thanks in advance !!

Regards,
Soundar P
 
Dear Developers,

I would like to send notification of public group users by using batch class(weekly based). can anyone please advise me how can i change my code for accurate requirement.

Batch Class 
global class PSO_etmfErrorLogBatch implements database.batchable<SObject>{

global database.querylocator start(database.batchableContext bc){
    system.debug('Start Method Running');
    return Database.getQueryLocator('Select Id,name from eTMF_Files_Error_Log__c');
}

global void execute(database.batchableContext bc, List<eTMF_Files_Error_Log__c> errlogList){
    system.debug('Execute Method Running');
    List<String> toAddresses = new List<String>();
    List<User> userList = [select id, name, email, isactive, profile.name, userrole.name, usertype 
                           from user 
                           where id in (select userorgroupid from groupmember where group.name = 'Document Tracking Admin')];
    for(User u : userList){           
        toAddresses.add(u.email);
    }  
    List < Messaging.SingleEmailMessage > emails = new List < Messaging.SingleEmailMessage > ();
    for (eTMF_Files_Error_Log__c irow_erLog : errlogList) {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(toAddresses});
        email.setSubject('Last Week ETMF Error Log'); 
        email.setPlainTextBody('Dear user, Please Check Last Week ETMF Error Log');
        emails.add(email);
    }
    Messaging.sendEmail(emails);
}

global void finish(database.batchableContext bc){}

}

Hearty Thanks In Advance !!

Regards,
Soundar P
Hi, 

 1. Roles are the combination of the Permission set, The user has access to Study object.
 2 . The problem is when I query a Study Object for which he does not has access to.
 3 . Here , Study is private.

How can i overcome this issue???

Thanks in advance !!!!

Regards,
Soundar Raj
 
Dears,

Can Anyone give me a good solution !!

Example:- 

Person A and Person B Working in Same company , Person A Will not continue his job hereafter. Suddenly he leaves his job without give any information. So Person B need to handle him record as well. How it's Possible ???

1. Person A Using Different Profile .

2. Person A Records OWD is Private.

3. How person B can access that records ???


Thanks In Advance !

Regards,
Soundar P
Dear Friends,

Error : First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]

I Got above Error When i try to save Contact records from VF Page. Could You please give me a best Solution.


*****************************          Class           *****************
 
Public Class Update_KYC{
    Public Id CurntRecId{Get;Set;}
    Private Final Account AccId;
    Public Account acc{Get;Set;}
    Public List<Contact>  ConList{Get;Set;}
    Public List<Risk__c>  RiskList{Get;Set;}
    Public Account accrec{GET;SET;}
    Public Contact accLkp{Get;Set;}
    public List<Contact> deleteContactList = new List<Contact>();
    public List<Risk__c> deleteRiskList = new List<Risk__C>();
    
    
    
    Public Update_KYC(Apexpages.StandardController AccController){
        AccId  = (Account)AccController.GetRecord();
        ConList = New List<Contact>();
        Contact con = New Contact();
        con.AccountId =  AccId.Id;
        ConList.add(con);
        
        /*For Risk*/
        RiskList =  New List<Risk__c>();
        Risk__c rsk = New Risk__c();
        rsk.Account__C = AccId.Id;
        RiskList.add(rsk);
        //accLkp = New Contact();
        
        
    }
    
    
        /*  ADD Contact */
    Public Void AddContactRow(){
        Contact con = New Contact();
        con.AccountId =  AccId.Id;
        ConList.add(con);
    }
    
    Public Void RemoveContactRow(){
        Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index'));
        if(ConList[indexVal - 1].Id != null)
        deleteContactList.add(ConList[indexVal - 1]);
        //Remove the contact from the table    
        ConList.remove(indexVal - 1);
    }
    
    Public Void SaveContact(){
        System.debug(' ******* Contact List **** |' + ConList);
        Insert ConList;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, + AccId.Name +  ' Contacts Added Successfully.');
        ApexPages.addMessage(myMsg); 
        
        ConList.Clear();
        ConList = New List<Contact>();
        Contact con = New Contact();
        con.Account =  AccId;
        ConList.add(con);
    }
    
         /*ADD RIKS*/

   Public Void AddRiskRow(){
       Risk__C rsk = New Risk__c();
       rsk.Account__c = AccId.Id;
       RiskList.add(rsk);
    }
    
    Public Void RemoveRiskRow(){
        Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index1'));
        if(RiskList[indexVal - 1].Id != null)
        deleteRiskList.add(RiskList[indexVal - 1]);
        //Remove the Risk from the table    
        RiskList.remove(indexVal - 1);       
    }
    
    Public Void SaveRisk(){
        Insert RiskList;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.INFO, + AccId.Name +  ' Risks Added Successfully.');
        ApexPages.addMessage(myMsg); 
        
        RiskList.Clear();
        RiskList= New List<Risk__c>();
        Risk__c rsk = New Risk__c();
        rsk.Account__c =  AccId.Id;
        RiskList.add(rsk);
    }
    
    
 }
**************************  VF Page *********************

 
<apex:page standardController="Account" Extensions="Update_KYC">
    <apex:form >
        <apex:pageBlock title="Update KYC Details" >
            <apex:pageBlockSection title="{!Account.Name} Details">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" />
                    <apex:outputField value="{!Account.Name}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.fields['Type'].label}" />
                    <apex:outputField value="{!Account.Type}"/>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.fields['Total_Disbursement_Amount__c'].label}" />
                    <apex:outputField value="{!Account.Total_Disbursement_Amount__c}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.fields['Total_Commitment_Amount__c'].label}" />
                    <apex:outputField value="{!Account.Total_Commitment_Amount__c}"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
        
        <apex:pageMessages ></apex:pageMessages>
        <apex:variable var="rowNumber" value="{!0}"/>
        <apex:pageblock title="Add Contacts" id="table1">
            <div style="overflow: scroll; width: 1200px; height: 280px;">
                <apex:pageBlockTable value="{!ConList}" var="con" id="theTable" styleClass="opp-table">
                    <apex:variable value="{!0}" var="cnt"/>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['FirstName'].label}">
                        <apex:inputField value="{!con.FirstName}" />
                    </apex:column>
                    <apex:column headerValue="LastName" >
                        <apex:inputField value="{!con.LastName}" />
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['AccountId'].label}">
                        <apex:outputField  id="Account" value="{!con.AccountId}"/>
                    </apex:column>  
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Relationship_ws__c'].label}">
                        <apex:inputField value="{!con.Relationship_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Constitution_ws__c'].label}">
                        <apex:inputField value="{!con.Constitution_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Is_Authorised_Signatory_ws__c'].label}">
                        <apex:inputField value="{!con.Is_Authorised_Signatory_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['CIN_ws__c'].label}">
                        <apex:inputField value="{!con.CIN_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Date_of_Incorporation_ws__c'].label}">
                        <apex:inputField value="{!con.Date_of_Incorporation_ws__c}" />
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['C_KYC_number_ws__c'].label}">
                        <apex:inputField value="{!con.C_KYC_number_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['PEP_ws__c'].label}">
                        <apex:inputField value="{!con.PEP_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['PAN_Card__c'].label}">
                        <apex:inputField value="{!con.PAN_Card__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Passport_No_ws__c'].label}">
                        <apex:inputField value="{!con.Passport_No_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Passport_Expiry_Date_ws__c'].label}">
                        <apex:inputField value="{!con.Passport_Expiry_Date_ws__c}"/>
                    </apex:column>
                    <apex:column headerValue="{!$ObjectType.Contact.fields['Aadhaar_Number__c'].label}">
                        <apex:inputField value="{!con.Aadhaar_Number__c}"/>
                    </apex:column>
                    <apex:column headerValue="Address Proof">
                        <apex:inputField value="{!con.Address_Proof_ws__c }"/>
                    </apex:column>
                    
                    <apex:column >
                        <apex:commandButton value=" Add " action="{!AddContactRow}" rerender="table1,error1" >
                        </apex:commandButton>
                    </apex:column>
                    <apex:column >
                        <apex:commandButton value="Remove" action="{!RemoveContactRow}" rerender="table1,error1" immediate="true" >
                            <apex:param name="index" value="{!cnt}"/>
                        </apex:commandButton> 
                        <apex:variable var="cnt" value="{!cnt+1}"/>     
                    </apex:column>
                </apex:pageBlockTable>
            </div>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value=" Save " action="{!SaveContact}" immediate="True" rerender="error1" />
                <apex:commandButton value="Cancel" action="{!Cancel}" immediate="True"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
        
        <apex:pageblock title="Add Risks" id="table2">
            <apex:pageBlockTable value="{!RiskList}" var="rsk">
            <apex:variable value="{!0}" var="cnt1"/>
                <apex:column headerValue="Risk Name">
                    <apex:inputField value="{!rsk.name}"/>
                </apex:column>
                <apex:column headerValue="Account">
                    <apex:outputField id="Account" value="{!rsk.Account__c}"/>
                </apex:column> 
                <apex:column headerValue="Received Date">
                    <apex:inputField value="{!rsk.Risk_Categorisation__c}"/>
                </apex:column>
                <apex:column headerValue="Received Date">
                    <apex:inputField value="{!rsk.KYC_Received_Date__c}"/>
                </apex:column>
                <apex:column headerValue="Received Date">
                    <apex:inputField value="{!rsk.KYC_Received_Date__c}"/>
                </apex:column>
                <apex:column headerValue="Review Date">
                    <apex:inputField value="{!rsk.KYC_Review_Date__c  }"/>
                </apex:column>
                <apex:column headerValue="Categorisation">
                    <apex:inputField value="{!rsk.Trust_Society__c}"/>
                </apex:column>
                <apex:column >
                    <apex:commandButton value=" Add " action="{!AddRiskRow}" rerender="table2,error2" immediate="true"/>
                </apex:column>
                <apex:column >
                    <apex:commandButton value="Remove" action="{!RemoveRiskRow}" rerender="table2,error2" immediate="true">
                        <apex:param name="index1" value="{!cnt1}"/>
                    </apex:commandButton> 
                        <apex:variable var="cnt1" value="{!cnt1+1}"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value=" Save " action="{!SaveRisk}" immediate="True"/>
                <apex:commandButton value="Cancel" action="{!Cancel}" immediate="True"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
        
        
        
        
    </apex:form>
</apex:page>
Regards,
Soundar.

 
Dear Friends,

I am trying to create Checklist_Details__c With WS_Sub_Checklist_Details__c  (As Available in Checklist_Master__c With Check_Point__c ) In Opportunity When Stage Change to Facility.

Please Refer My Code and give me an idea how can i achieve This Process.

************************************************   Trigger *********************************************
Map<Id,Opportunity> OptyMap = New Map<Id,Opportunity>();
    List<WS_Facility_Details__c> Fsd = New List<WS_Facility_Details__c>();
    Set<ID> PrdId = New Set<ID>();
    Set<ID> LnTpId = New Set<ID>();
    Set<ID> OppId = New Set<ID>();
    Map<ID, Checklist_Master__c> CkLstId = New  Map<ID, Checklist_Master__c>();
    List<Checklist_Master__c> CMList_Prod = New List<Checklist_Master__c>();
    List<Checklist_Master__c> CMList_LnTp = New List<Checklist_Master__c>();
    List<Checklist_Details__c> Fac_CMList_Prd = New List<Checklist_Details__c>();
    List<Checklist_Details__c> Fac_CMList_LnTp = New List<Checklist_Details__c>();
    List<WS_Sub_Checklist_Details__c> SubCPList = New List<WS_Sub_Checklist_Details__c>();
    List<Checklist_Details__c> CDList  = new List<Checklist_Details__c>();
    List<Check_Point__c> CPList = New List<Check_Point__c>();
    List<Checklist_Master__c > CLMaster = New List<Checklist_Master__c>();
    List<Check_Point__c> CPList1 = New List<Check_Point__c>();
    Map<ID,Check_Point__c> CPSet = New Map<ID,Check_Point__c>();
    Map<ID,Checklist_Details__c> CdSet = New  Map<ID,Checklist_Details__c>();
    Set<ID> CmSet = New Set<ID>();
    
    
    For(Opportunity opp : Trigger.New){
        IF(opp.StageName != Trigger.oldMap.get(opp.Id).StageName){
            If(opp.StageName == 'Facility'){
                OptyMap.Put(opp.Id, opp);
            }
        }
        
    }
    System.debug('OptyMap Size | ' + OptyMap.Size() );
    If(OptyMap.Size() > 0 && OptyMap.Size() !=Null){
        /* ------ Checkilist From Product ------ */
        Fsd = [Select id,name,Opportunity__c,Product__c, Loan_Type__c from WS_Facility_Details__c Where Opportunity__c IN : OptyMap.KeySet() Order By CreatedDate Desc];
        For(WS_Facility_Details__c irow_Fsd_Prd : Fsd){
            PrdId.add(irow_Fsd_Prd.Product__c);
            OppId .add(irow_Fsd_Prd.Opportunity__c);
        }
        If(PrdId.Size() !=Null && PrdId.Size() > 0){
            /*Adding CheckList In Opportunity From Product*/
                       
            Opportunity Crnt_Opp_Prd = [Select id,StageName From Opportunity Where ID IN : OppId];
            
            CLMaster = [Select Id,Name, Stage__c, CL_Product__c, Check_List__c,Loan_Type__c From Checklist_Master__c Where CL_Product__c IN : PrdId];
            
            For(Checklist_Master__c Irow_cm2 : CLMaster){
              CmSet.add(Irow_cm2.Id);
            }
          
            CPList = [Select Id,Checklist__c, Checklist_Master__c From Check_Point__c Where Checklist_Master__c IN : CPSet.KeySet()];

                For(Checklist_Master__c irow_CM_Prd : CLMaster){
                    Checklist_Details__c CM_New = New Checklist_Details__c();
                    CM_New.Checklist_Master__c = irow_CM_Prd.Id;
                    CM_New.Stage__c= irow_CM_Prd.Stage__c;
                    CM_New.Checklist__c= irow_CM_Prd.Check_List__c;
                    CM_New.Opportunity__c = Crnt_Opp_Prd.Id ;
                    Fac_CMList_Prd.add(CM_New);
                    //CkLstId.Put(irow_CM_Prd.Id, irow_CM_Prd);
            }
            }
            System.debug('******** SubCPList ********'  + 'SubCPList.Checklist_Details__c');
            /*Ready to Insert Checklist Details From Product*/
            If(Fac_CMList_Prd.Size()>0 && Fac_CMList_Prd.Size() != Null){
                Insert Fac_CMList_Prd; 
               
                for(Checklist_Details__c irow_Cm : Fac_CMList_Prd){
                    CDSet.Put(irow_Cm.id,irow_Cm);
                }
                
                CDList = [Select id From Checklist_Details__c Where ID IN : CDSet.KeySet()];
                
                For(Check_Point__c Irow_cp : [Select Id,Checklist__c, Checklist_Master__c From Check_Point__c Where Checklist_Master__c IN : CmSet]){
                    WS_Sub_Checklist_Details__c  SubCD = New WS_Sub_Checklist_Details__c();
                    SubCD.Checklist__c = Irow_cp.Checklist__c;
                    For(Checklist_Details__c Irow_cp1 :  CDList){
                    IF(CDSet.containskey(Irow_cp1.Id)){
                    SubCD.Checklist_Details__c = Irow_cp1.Id;
                    }
                    }
                    SubCPList.add(SubCD);
                
            }
            
           System.debug('*********SubCPList | ' + SubCPList.Size());
            IF(SubCPList.Size() > 0 && SubCPList.Size() != NUll){
                Insert SubCPList;
            }
        }
        
}


I 'll feel Happy When You give a good Solution !!!!
Regards,
Soundar.
Dears,

I need to display an amount in table <Td> (calculating With Percentage - This value also available <td> in same row <tr>).

Step 1 : Enter An Amount  (Example : 1000)

Step2  : Entered Amound need to Calculate with Percentage (Example : 10%  (10/100) * 1000)

Step 3 :  Calculated Amount should be display in another <Td>.

User-added image
 
Controller 
---------------------------------------------------------------------------
public with sharing class WholeSale_User_Stories{
    
    Public Account acc {get;set;}
    Public Integer EnteredAmount{get;set;}
    //Public Integer secondNumber{get;set;}
    Public Integer result{get;set;}
    Public List<Exposure_Limit_WS__c> expLimitList{get;Set;}
    
    public WholeSale_User_Stories(ApexPages.StandardSetController controller) {
    }
    
    public WholeSale_User_Stories()
    {
        expLimitList = [Select id,name ,Particulars__c,Standard_Limit_Percentage__c From Exposure_Limit_WS__c];
        acc = New Account();
        
        /*for(Exposure_Limit_WS__c expLimit : expLimitList){
stanPer = expLimit.Standard_Limit_Percentage__c;

}*/
    }
    
    Public PageReference init(){
        EnteredAmount = 0;
        //secondNumber = 0;
        result = 0;
        return Null;
    }
    
    Public PageReference doSum(){
        EnteredAmount= EnteredAmount== Null ? 0 : EnteredAmount; 
        //secondNumber = secondNumber == Null ? 0 : secondNumber; 
        System.debug('************Entered Amount ' + EnteredAmount);
        result = EnteredAmount; //test
        System.debug('############result | ' + result);
        return Null;
    }
        
    //Wrapper Class
    
    /*Public Class WholeSaleWrapper{

Public double StandardLimitPercent;

public WholeSaleWrapper(Exposure_Limit_WS__c exp){
StandardLimitPercent = exp.Standard_Limit_Percentage__c;
}

}*/
  
}
 
VF Page
--------------------------------------------------------------------
<apex:page sidebar="False" showHeader="False"  controller="WholeSale_User_Stories">
<apex:form id="frm">
  <html>
  <head>
  
  <!-- Bootstrap Online Link -->
  <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous" />
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  
  <style>
  
  </style>
  </head>
  <body>
   
  <div><br/><br/><br/><br/></div>
  <div class="container">
  <div class="row col-sm-12" align="center">
  <div class="form-group col-sm-6" align="right">
  <apex:outputLabel >Selected Borrower &nbsp;&nbsp;&nbsp;</apex:outputLabel> 
  <apex:inputField value="{!acc.Parentid}"/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </div>
  <div class="form-group col-sm-4" >
  <apex:outputLabel for="theTextInput1">Enter Amount &nbsp;&nbsp;&nbsp;</apex:outputLabel> <apex:inputText value="{!EnteredAmount}" id="theTextInput1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <!--<apex:outputlabel  value="Result Is : {!result}" for="theTextInput2"></apex:outputlabel >  -->
  </div>
  <div class="form-group col-sm-2" align="left">
<!--  <button type="button" class="btn btn-info" styleClass="buttonStyle" style="background:#388A9D" >Calculate</button> -->
<apex:commandButton action="{!doSum}" value="Calculate" style="background:#52D7F5"/>
  </div>
 <br/>  <br/>
  </div>
         
  <table border="1" width="100%">
  <!--<tr>
  <td colsapn="6">Owned Funds Amount INR</td>
  <td width="10%"></td>
  <td width="10%"></td>
  </tr> -->
  
  <tr bgcolor="#DAF3FC" style="font-weight:bold">
  <td rowspan="2" colspan="2" align="center">Particulars</td>
  <td width="10%" rowspan="2" align="center">Standard Limit in % for Loan Company</td>
  <td  colspan="2" align="center">Infrastructure Finance Company</td>
  <td  colspan="2" align="center"> AFC and LC (only for Infrastructure Loan and/ or Investment)</td>
  <td width="17%" align="center" rowspan="2">Exposure Limits in Amount INR</td>
  <td align="center" rowspan="2">Exposure Limits in Amount INR ( For Non PPP projects and PPP projects Non Tripartite cases)</td>
  
  </tr>
  
  <tr bgcolor="#DAF3FC" style="font-weight:bold">
  <td width="11%" align="center">Additional limit %</td>
  <td width="11%" align="center">Total Limit %</td>
  <td width="10%" align="center">Additional limit ***</td>
  <td width="12%" align="center">Total Limit</td>
  </tr>
  
  <apex:repeat value="{!expLimitList}" var="whlsl">
  <tr>
  <td width="7%" align="center"><apex:outputText value="{!whlsl.Particulars__c}" ></apex:outputText></td>
  <td width="9%" align="center"><apex:outputText value="{!whlsl.Name}"></apex:outputText> </td>
  <td Align="center"><apex:outputText value="{!whlsl.Standard_Limit_Percentage__c}"  ></apex:outputText>%</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td bgcolor="#E6F4C8" align="center">{!result}</td>
  <td bgcolor="#E6F4C8" align="center">--</td>
  </tr>
  </apex:repeat>
 
  </table>
  
  </div> <!-- Container Closed -->
  </body>
  </html>
  </apex:form>
  </apex:page>

Thanks In Advance.

Regards,
Soundar.
 
Dears,

Is it possible to hide a currency symbol in detail page ??

1. I have a custom field with the name of amount .

2. This field is displaying a value with INR (For Example : INR 1000.00)

3. My Expectation is , need to display an amount without INR  (For Example : 1000.00)

Is That Possible in salesforce 

Regards,
Soundar.
Hi ,

I like to display a dependent autocomplete in visualforce page.

1. Case reason (Auto Complete)

2.Case Disposition (Dependent on Case Reason)

Here i have using 2 @Remote action

Can anyone help me how can i achieve this process

Note  : I didn't get case reason Id in Case Disposition query

Class
===========================================
global class AutoCompleteCtr
{
    public static List<String> CsRsnLst{get;set;}
    public static List<String> CsDispLst{get;set;}
    public String Rsn_Name{get;set;}
    public String Disp_Name{get;set;}
    public String successMessage{get;set;}
    Public Case_Reason__c csr_reason{Get;Set;}
    Static ID CsRsn_Id{Get;Set;}
    Static Id CsDisp_Id{Get;Set;}
    Public Id Case_ID{get;set;}
    
    Public AutoCompleteCtr(ApexPages.StandardController controller){
        
    }
    
    /*Case Reason*/
    @RemoteAction
    global static String[] populateCaseRsnByName(String value)
    {
        try
        {
            CsRsnLst=new List<String>();
            if(String.isNotBlank(value))
            {
                value= '%'+value+'%';
                List<Case_Reason__c> Rsn_lst=[Select Id,name from Case_Reason__c where name LIKE:value];
                for(Case_Reason__c irow_rsn : Rsn_lst)
                {
                    CsRsnLst.add(irow_rsn.name);
                }
            }
            System.debug('CsRsnLst | ' + CsRsnLst);
            return CsRsnLst;
        } 
        catch(Exception e)
        {
            System.debug('Message:='+e.getMessage()+'**Line Number='+e.getLineNumber());
        }
        return null;
    }
 
    public void SelectCasereason()
        
    {
        try
        {
            Rsn_Name=ApexPages.currentPage().getParameters().get('CaseReasonName');
            if(String.isNotBlank(Rsn_Name))
            {
                 csr_reason =[select id,name from Case_Reason__c where Name=:Rsn_Name];
                System.debug('csr_reason ' + csr_reason);
                csr_reason.Name ='Autocomplete';
                CsRsn_Id = csr_reason.Id;
                System.debug('Case Reason Id | ' + CsRsn_Id);
            }
        }
        catch(Exception e)
        {
            System.debug('Message:='+e.getMessage()+'**Line Number='+e.getLineNumber());
        }
    }
    /*Case Disposition Remote Action*/
    @RemoteAction
    Global static String[] populateCaseDispByName(String value)
    {
        try
        {
            //Id CsRsn_Id;
            //System.debug('Case REason Id | '+ CsRsn_Id);
            CsDispLst=new List<String>();
            if(String.isNotBlank(value))
            {
                value= '%'+value+'%';
                System.debug('Case Reason Id | ' + CsRsn_Id);
                List<Case_Disposition__c> Disp_lst=[Select Id,name,Case_Reason__c  from Case_Disposition__c where  name LIKE:value  AND Case_Reason__c =: CsRsn_Id];
                System.debug('Disp_lst Size | ' + Disp_lst.size());
                for(Case_Disposition__c irow_disp : Disp_lst)
                {
                    CsDispLst.add(irow_disp.name);
                }
            }
            return CsDispLst;
        } 
        catch(Exception e)
        {
            System.debug('Message:='+e.getMessage()+'**Line Number='+e.getLineNumber());
        }
        return null;
    }
    public void SelectCaseDisp()
    {
        try
        {
            Disp_Name=ApexPages.currentPage().getParameters().get('caseDispName');
            if(String.isNotBlank(Disp_Name))
            {
                Case_Disposition__c csr_Dispn =[select id,name from Case_Disposition__c where Name=:Rsn_Name];
                csr_Dispn.name ='Autocomplete';
                CsDisp_Id = csr_Dispn.Id;
            }
        }
        catch(Exception e)
        {
            System.debug('Message:='+e.getMessage()+'**Line Number='+e.getLineNumber());
        }
    }
    
    //Save Into Case
    Public void Save(){
        Case_ID = Apexpages.currentPage().getParameters().get('Id');
        Case cs = New Case();
        cs.Id = Case_Id;
        cs.Reason__c = CsRsn_Id;
        cs.Case_Disposition__c = CsDisp_Id;
        update cs;
    }
}



VF-PAge
=====================================
<apex:page standardController="Case" extensions="AutoCompleteCtr" sidebar="false" showHeader="false">
    <html lang="en">  
        <head>
            <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
            <meta charset="utf-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <title>Case Reason Autocomplete</title>
            <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
            <link rel="stylesheet" href="/resources/demos/style.css"/>
            <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
            <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
            <!--Case Reason Auto Complete -->
            <script>
            $( function() {
                $( "#tags" ).autocomplete({
                    source: function(request, response) {
                        Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.AutoCompleteCtr.populateCaseRsnByName}',
                                                                  request.term,
                                                                  function(result, event){
                                                                      if (event.status)
                                                                      {
                                                                          console.log(result);
                                                                          response(result);
                                                                      }
                                                                      else
                                                                      {
                                                                          alert(event.message);
                                                                      }
                                                                  });
                    },
                    select:function( event, ui ){
                        // Call class method by passing this value using action function            
                        callControllermethod(ui.item.label);
                    }
                });
            } );
            </script>
            <!--Case Disposition Auto Complete -->
            <script>
            $( function() {
                $( "#tags1" ).autocomplete({
                    source: function(request, response) {
                        Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.AutoCompleteCtr.populateCaseDispByName}',
                                                                  request.term,
                                                                  function(result, event){
                                                                      if (event.status)
                                                                      {
                                                                          console.log(result);
                                                                          response(result);
                                                                      }
                                                                      else
                                                                      {
                                                                          alert(event.message);
                                                                      }
                                                                  });
                    },
                    select:function( event, ui ){
                        // Call class method by passing this value using action function            
                        callControllermethod(ui.item.label);
                    }
                });
            } );
            </script>
        </head>
        <body >
            <apex:form >
                <apex:actionRegion >
                    <apex:actionFunction name="callControllermethod" action="{!SelectCasereason}" reRender="mssge">
                        <apex:param name="CaseReasonName" value=""/>
                    </apex:actionFunction>
                    <apex:actionFunction name="callControllermethod" action="{!SelectCaseDisp}" reRender="mssge">
                        <apex:param name="caseDispName" value=""/>
                    </apex:actionFunction>
                </apex:actionRegion> 
                <div class="Container" >
                    <div class="ui-widget">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="col-sm-6">
                                    <label for="tags" class="pull-right">Case Reason </label>   
                                </div>
                                <div class="col-sm-6">
                                    <input id="tags"  />  
                                </div>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="ui-widget">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="col-sm-6">
                                    <label for="tags1" class="pull-right">Case Disposition </label> 
                                </div>
                                <div class="col-sm-6">
                                    <input id="tags1" />
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <br/> <br/>
                    <div class="form-group">
                        <div class="col-sm-12">
                            <div class="col-sm-6">
                            </div>
                            <div class="col-sm-6">
                                <apex:commandButton action="{!Save}" value="Proceed" styleClass="buttonStyle" style="background: #E6E6FA"/>
                            </div>
                        </div>
                    </div>
                </div>
                <!--<apex:outputPanel id="mssge">
<div style="margin: 5px;color: green;">{!successMessage}</div>
</apex:outputPanel>-->
            </apex:form>
        </body>
    </html>
</apex:page>




Thanks in Advance
Hi,

1. Case Created When SMS_Transaction__c Creation.
2. I Need To Add Account In Case Record (Based On The Mobile Number).
Add Account IF(Account.PersonMobile == SMS_Transaction__c.Mobile__Number__c).

Kindly Refer The Following Code And Advise me how it's Possible.
 
trigger CasecreationBySMS on SMS_Transaction__c (After Insert, After Update) {
    System.debug('Case Creation By Sms');
    Set<Id> smsTransId  = New Set<Id>();
    Set<String> phone = New Set<String>();
    List<Case> stList = New List<Case>();
    Map<Id,Id> accMap  = New Map<Id,Id>(); 
    
    For(SMS_Transaction__c s : Trigger.New){
        If(s.Event__c == 'TKT' || s.Event__c == 'MsCall1' || s.Event__c == 'MsCall2'){
            smsTransId.add(s.Id);
            System.debug('SMS ID  |' + smsTransId);
        }
        IF(s.Mobile_Number__c !=Null){
            phone.add(s.Mobile_Number__c);
        }
    }
    
    If(smsTransId.size() > 0){
        List<SMS_Transaction__c> st = [Select id,name,Received_Text__c  from SMS_Transaction__c Where ID IN: smsTransId];
        //List<Account> acc = [Select id,name,PersonHomePhone From Account Where PersonHomePhone IN : phone ORDER BY CreatedDate DESC LIMIT 1];
        For(Account acc : [Select id,name,PersonHomePhone From Account Where PersonHomePhone IN : phone ORDER BY CreatedDate DESC LIMIT 1]){
            accMap.put(acc.PersonHomePhone, acc.Id);
        }
        For(SMS_Transaction__c s1 : st){
            Case c = New Case();
            c.Priority = 'Medium';
            c.Status = 'New';
            c.Description = s1.Received_Text__c;
            IF(s1.Mobile_Number__c == accMap.get(acc.PersonHomePhone).Mobile_Number__c){
                c.AccountId = accMap.get(s1.Mobile_Number__c).AccountId;
            }
            stList.add(c);
        }
        System.debug('stList Size | ' + stList.size());
        IF(stList.size() > 0){
            Insert stList;
        }
    }

}

Thanks ,

Soundar.
HI,

I like to update a Queue Owner ,

1. Display all queue's in visualforce page
2. select a Queue by dropdown 
3. Update current owner by click save button.


Can anyone explain how i can achieve this Process.

Thanks,
Soundar. 
How can we display a visualforce page in child tab by a (Detail Page) button click.

Regards,
Soundar.
HI,

I can't get the CaseID from Case activity based on the condition. Can Anyone please check and let me know how can i solve this problem.

Trigger
/* 
Name          : BusinesStatusAndStatusUpdate
Description   : Update Receive Document , Receive & Track Credit Balance, Contact Provider, Confirm Credit Balance,Verify Provider Billing Issues And Create a New Case
Created By    : OrbitTeam_Soundar
Created Date  : 08/11/2017 
*/

trigger BusinesStatusAndStatusUpdate on Case_Activity__c (After Update) {
    Set<Id> caseId = New Set<Id>();
    List<Case_Activity__c> casActList = New List<Case_Activity__c>();
    List<Case_Activity__c> Up_casActList = New List<Case_Activity__c>();
    //For Getting a record Type
    Id creditbalreportId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive And Track Credit Balance').getRecordTypeId();
    System.debug('Credit Balance Report recordType name |' + creditbalreportId );
    string ownerId =''; 
    For(Case_Activity__c ca : Trigger.New){
        system.debug('Checking for CaseId ');
        If(ca.Case__c != Null && ca.RecordtypeId == creditbalreportId && ca.Activity_Business_Status__c == 'Credit Balance Reported' 
        && ca.Case__r.Type=='Credit – Balance Recoupment'){
            ownerId  = ca.Case__r.OwnerId;
            caseId.add(ca.Case__c);
            System.debug('Case ID | ' + caseId);
        }
    }
    
    Id receiveDocId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive Document').getRecordTypeId();
    System.debug('receive doc Rec |' + receiveDocId );
    Id ContProviderId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Contact Provider').getRecordTypeId();
    System.debug('Contact Provider Rec |' + ContProviderId );
    Id ConCredBalId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Confirm Credit Balance').getRecordTypeId();
    System.debug('Credit Balance Rec |' + ConCredBalId );
    Id BillIssueId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Verify Provider Billing Issues').getRecordTypeId();
    System.debug('Billing Issue Rec |' + BillIssueId );
    
    list<id> st_RecTyId = new list<id>();
    st_RecTyId.add(creditbalreportId);
    st_RecTyId.add(receiveDocId);
    st_RecTyId.add(ContProviderId);
    st_RecTyId.add(ConCredBalId);
    st_RecTyId.add(BillIssueId);
    
    List<Case_Activity__c> caActList = [Select id,Name, Case__c,Activity_Business_Status__c,Status__c  from Case_Activity__c Where Case__c  =:CaseId AND RecordTypeId IN: st_RecTyId];
    
    for(Case_Activity__c cAct : caActList){
        If(cAct.Activity_Business_Status__c != 'Activity Not Applicable'){
            cAct.Activity_Business_Status__c = 'Activity Not Applicable';
        }
        if(cAct.Status__c != 'Completed'){
            cAct.Status__c = 'Completed';
        }
        Up_casActList.add(cAct);
    }

    
    System.debug('casActList Size | ' + casActList.size());
    If(Up_casActList.size() > 0){
        Update Up_casActList;
        Case cs = new Case();
        cs.Case_Name__c= 'Provider Audit - Onsite';
        cs.Type='Provider Audit - Onsite';
        cs.OwnerId = ownerId;
        insert cs;
    }

}

Thanks In Advance.

Soundar.

Hi ,

I am getting below Error when i am trying to update a "Contact Name" in Case Object (In After Insert). 

Error  : PrimaryAssociateType: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id 5001F000000w4LpQAI; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.PrimaryAssociateType: line 60, column 1

My Trigger

trigger PrimaryAssociateType on Case_Associate__c (Before Insert, After Insert) {
    
    Set<Id> caseId = New Set<Id>();
    set<Id> caseId1 = New Set<Id>();
    List<case> updtCon = New List<case>();
    Map<Id,Case_Associate__c> casMap  = New Map<Id,Case_Associate__c>(); 
    
    if(Trigger.isBefore && Trigger.isInsert){
        For(Case_Associate__c  ca : Trigger.New){
            If(ca.Case_Number__c != Null){
                CaseId.add(ca.Case_Number__c);
                System.debug('Case Number | ' + CaseId);
            }
        }
        
        IF(CaseId.size() > 0){
            List<Case_Associate__c> cas = [Select id,name,Case_Number__c,Associate_Type__c from Case_Associate__c Where Case_Number__c =:CaseId AND Associate_Type__c = 'Primary'];
            System.debug('Case Associate Type With Primary |' + cas);
            System.debug('Size Of Primary | ' + cas.Size());
            Case_Associate__c cast1 = New Case_Associate__c();
            String curPage = ApexPages.currentPage().getUrl();
            IF(cas.Size() > 0 && curPage.contains('Primary')){
                System.debug('Primary is Already Created');
                for(Case_Associate__c  cas1 : Trigger.New){
                    cas1.addError('Primary Associate Type was Already Created. So Please Choose "Secondary" or "Other" ');
                } 
            } else {
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Case Associate Created Successfully'));
                System.debug('Secondary || Other');
            }
        }
    }
    
    if(Trigger.isAfter && Trigger.isInsert){  
        For(Case_Associate__c ca1 : Trigger.New){
            IF(ca1.Case_Number__c != Null && ca1.Entity_Type__c == 'Provider' && ca1.Associate_Type__c == 'Primary'){
                caseId1.add(ca1.Case_Number__c);
                casMap.put(ca1.Case_Number__c,ca1);
                System.debug('Case Number 1 | ' + caseId1);
            }
        } 
        
        System.debug('caseId1.size() | ' + caseId1.size());
        IF(caseId1.size() > 0){
            for(string irow : casMap.keyset()){
                Case c = New Case(id=irow);
                System.debug('&&&&&&& irow |'+ irow);
                c.ContactId = casMap.get(irow).Entity1__c;
                system.debug('Contact Id |' + c.ContactId);
                updtCon.add(c);
            }
            System.debug('&&&&&&&&&  Size Of updtCon |' + updtCon.size());
            If(updtCon.size() > 0){
                Insert updtcon;
            }
        }
    }
}
Regards,
Soundar.
trigger Sumoftotalamount on Opportunity (after insert,after update) {
    set<id>accid = new set<id>();
    List<opportunity> oppList = new List<opportunity>();
    
    for(Opportunity op:Trigger.new){
        
        accid.add(op.Accountid);
        
    }
    list<Account> acc =[select Id,name,Rollup_Amount_Y__c,Rollup_Amount_X__c,Rollup_Amount__c from Account where Id=:accid];
    Map<id,Account> accmap = new Map<id,Account>();
    for(Account ac: acc){
        accmap.put(ac.Id,ac);
    }
    if(trigger.isinsert){
        for(Opportunity op :Trigger.new){
            if(accmap.containskey(op.Accountid)){
                Decimal sum=0;
                Account a = accmap.get(op.Accountid);
                
                
                if(op.type__c== 'positive'){
                    if(op.Amount_X__c!=null){
                        If(a.Rollup_Amount_X__c==null){
                            a.Rollup_Amount_X__c=op.Amount_X__c;
                            accmap.put(op.Accountid,a );
                        }
                        else {
                            a.Rollup_Amount_X__c=a.Rollup_Amount_X__c + op.Amount_X__c;
                            accmap.put(op.Accountid,a );
                        }
                    }
                }
                
                if(op.type__c== 'negative'){
                    if(op.Amount_Y__c!=null){
                        If(a.Rollup_Amount_Y__c==null){
                            a.Rollup_Amount_Y__c=op.Amount_Y__c;
                            accmap.put(op.Accountid,a );
                        }
                        else {
                            a.Rollup_Amount_Y__c=a.Rollup_Amount_Y__c + op.Amount_Y__c;
                            accmap.put(op.Accountid,a );
                        }
                    }
                }
                if(a.Rollup_Amount__c==null)  {
                    a.Rollup_Amount__c=a.Rollup_Amount_Y__c+a.Rollup_Amount_X__c;
                    accmap.put(op.Accountid,a );
                }
                else{
                    a.Rollup_Amount__c=a.Rollup_Amount__c+(a.Rollup_Amount_X__c+a.Rollup_Amount_Y__c);
                    accmap.put(op.Accountid,a );
                }
            }
        }
        update accmap.values();
        
    }
    
    if(trigger.isupdate){
        for(Opportunity op:Trigger.new){
            if(op.AccountId!=trigger.oldmap.get(op.Id).Accountid){
                if(op.type__c==trigger.oldmap.get(op.Id).type__c && op.type__c== 'positive'){
                    //new opportunity 'account id' is not equal to old oppertunity Account id {change Account id}// 
                    if(accmap.containskey(op.Accountid)){
                        Account a = accmap.get(op.Accountid);
                        if(a.Rollup_Amount_X__c==null){
                            a.Rollup_Amount_X__c=op.Amount_X__c;
                        }
                        else{
                            a.Rollup_Amount_X__c =  a.Rollup_Amount_X__c+op.Amount_X__c;
                            accmap.put(op.Accountid,a );
                        }
                        if(accmap.containskey(trigger.oldmap.get(op.Id).Accountid)){
                            Account a1 = accmap.get(trigger.oldmap.get(op.Id).Accountid);
                            a1.Rollup_Amount_X__c =  a1.Rollup_Amount_X__c - op.Amount_X__c;
                            accmap.put(trigger.oldmap.get(op.Id).Accountid,a1 );
                        }
                    }
                }
                else if(op.type__c!=trigger.oldmap.get(op.Id).type__c && op.type__c== 'positive'){//it changed from negative to positive & account is also changed
                    if(accmap.containskey(op.Accountid)){
                        Account a = accmap.get(op.Accountid); 
                        if(a.Rollup_Amount_X__c==null){
                            a.Rollup_Amount_X__c=op.Amount_X__c;
                            accmap.put(op.Accountid,a );
                        }  
                        else
                        {
                            a.Rollup_Amount_X__c= a.Rollup_Amount_X__c + op.Amount_X__c;
                            accmap.put(op.Accountid,a );
                        }
                        
                        if(a.Rollup_Amount__c!=null||op.Amount_Y__c==null||op.Amount_X__c==null){
                            a.Rollup_Amount__c=a.Rollup_Amount__c+(op.Amount_X__c+op.Amount_Y__c);
                            accmap.put(op.Accountid,a );     
                        }
                        else{
                            a.Rollup_Amount__c= (a.Rollup_Amount_X__c+a.Rollup_Amount_Y__c);
                            accmap.put(op.Accountid,a );
                        }              
                        if(accmap.containskey(trigger.oldmap.get(op.Id).Accountid)){
                            Account a1 = accmap.get(trigger.oldmap.get(op.Id).Accountid);
                            If(a1.Rollup_Amount_Y__c!=null){
                                a1.Rollup_Amount_Y__c=a1.Rollup_Amount_Y__c-op.Amount_Y__c;
                                accmap.put(op.Accountid,a1 ); 
                            }
                            a1.Rollup_Amount__c =  a1.Rollup_Amount__c - (trigger.oldmap.get(op.Id).Amount_Y__c+trigger.oldmap.get(op.Id).Amount_X__c);
                            accmap.put(op.Accountid,a1 );
                        }
                    }
                }
                
                if(op.type__c==trigger.oldmap.get(op.Id).type__c && op.type__c== 'negative'){
                    if(accmap.containskey(op.Accountid)){
                        Account a = accmap.get(op.Accountid);
                        if(a.Rollup_Amount_Y__c==null){
                            a.Rollup_Amount_Y__c=op.Amount_Y__c;
                        }
                        
                        else{
                            a.Rollup_Amount_Y__c =  a.Rollup_Amount_Y__c+op.Amount_Y__c;
                            accmap.put(op.Accountid,a );
                        }      
                    }
                    if(accmap.containskey(trigger.oldmap.get(op.Id).Accountid)){
                        Account a1 = accmap.get(trigger.oldmap.get(op.Id).Accountid);
                        a1.Rollup_Amount_Y__c =  a1.Rollup_Amount_Y__c -op.Amount_Y__c;
                        accmap.put(op.Accountid,a1);
                    }
                }
                else if(op.type__c!=trigger.oldmap.get(op.Id).type__c && op.type__c== 'negative'){//changed from positive to negative
                    if(accmap.containskey(op.Accountid)){
                        Account a = accmap.get(op.Accountid); 
                        if(a.Rollup_Amount_Y__c==null){
                            a.Rollup_Amount_Y__c=op.Amount_Y__c;
                            accmap.put(op.Accountid,a );
                        }  
                        
                        else
                        {
                            a.Rollup_Amount_Y__c= a.Rollup_Amount_Y__c + op.Amount_Y__c;
                            accmap.put(op.Accountid,a );
                        }
                        if(a.Rollup_Amount__c!=null){
                            a.Rollup_Amount__c=a.Rollup_Amount__c+(a.Rollup_Amount_X__c+a.Rollup_Amount_Y__c);
                            accmap.put(op.Accountid,a);
                        }
                        else{
                            a.Rollup_Amount__c= (a.Rollup_Amount_X__c+a.Rollup_Amount_Y__c);
                            accmap.put(op.Accountid,a);
                        } 
                        if(accmap.containskey(trigger.oldmap.get(op.Id).Accountid)){
                            Account a1 = accmap.get(trigger.oldmap.get(op.Id).Accountid);
                            If(a1.Rollup_Amount_X__c!=null){
                                a1.Rollup_Amount_X__c= a1.Rollup_Amount_X__c-op.Amount_X__c;
                                accmap.put(op.Accountid,a1 ); 
                            }
                            a1.Rollup_Amount__c =  a1.Rollup_Amount__c - (trigger.oldmap.get(op.Id).Amount_X__c+trigger.oldmap.get(op.Id).Amount_Y__c);
                            accmap.put(op.Accountid,a1 );
                        }
                    }
                    
                }
            }
            else if(op.AccountId==trigger.oldmap.get(op.Id).Accountid){  //same account but change type
                Account a = accmap.get(op.Accountid);
                if(op.type__c!=trigger.oldmap.get(op.Id).type__c && op.type__c== 'positive'){
                    if(a.Rollup_Amount_X__c==null){
                        a.Rollup_Amount_X__c= op.Amount_X__c;
                        accmap.put(op.Accountid,a);
                    }else{
                        Decimal sum = op.Amount_X__c - trigger.oldmap.get(op.Id).Amount_X__c;
                        a.Rollup_Amount_X__c=a.Rollup_Amount_X__c+sum;
                        accmap.put(op.Accountid,a);
                    }
                }
                else if(op.type__c!=trigger.oldmap.get(op.Id).type__c && op.type__c== 'negative'){
                    if(a.Rollup_Amount_Y__c==null ){
                        a.Rollup_Amount_Y__c= op.Amount_Y__c;
                        accmap.put(op.Accountid,a);
                    }
                    else{
                        Decimal sum = op.Amount_Y__c - trigger.oldmap.get(op.Id).Amount_Y__c;
                        a.Rollup_Amount_Y__c=a.Rollup_Amount_Y__c+a.Rollup_Amount_Y__c+sum;
                        accmap.put(op.Accountid,a);
                        
                    }
                }
                else if(op.type__c==trigger.oldmap.get(op.Id).type__c && op.type__c== 'positive'){
                    if(op.Amount_X__c!=trigger.oldmap.get(op.Id).Amount_X__c){
                        if(a.Rollup_Amount_X__c==null && op.Amount_X__c!=null){
                            a.Rollup_Amount_X__c=op.Amount_X__c;
                            accmap.put(op.Accountid,a); 
                        }
                        else{
                            if(a.Rollup_Amount_X__c!=null && op.Amount_X__c!=null){
                                a.Rollup_Amount_X__c=a.Rollup_Amount_X__c-trigger.oldmap.get(op.Id).Amount_X__c;
                                a.Rollup_Amount_X__c=a.Rollup_Amount_X__c+op.Amount_X__c;
                                accmap.put(op.Accountid,a); 
                                
                            }
                        }
                        
                    }
                }
                
                else if(op.type__c==trigger.oldmap.get(op.Id).type__c && op.type__c== 'negative'){
                    if(op.Amount_Y__c!=trigger.oldmap.get(op.Id).Amount_Y__c){
                        if(a.Rollup_Amount_Y__c==null && op.Amount_Y__c!=null){
                            a.Rollup_Amount_Y__c=op.Amount_Y__c;
                            accmap.put(op.Accountid,a); 
                        }
                        
                        else{
                            if(a.Rollup_Amount_Y__c!=null && op.Amount_Y__c!=null){
                                a.Rollup_Amount_Y__c=a.Rollup_Amount_Y__c-trigger.oldmap.get(op.Id).Amount_Y__c;
                                a.Rollup_Amount_Y__c=a.Rollup_Amount_Y__c+op.Amount_Y__c;
                                accmap.put(op.Accountid,a); 
                                
                            }
                        }
                    }      
                    
                }
                
                
            }
            update accmap.values();
        }
    }
}
Dears,

1. I changed lookup to picklist in vf page
2. Selected picklist value is not saved in corresponding field.

Can anyone please advise ??

@controller
Public Class lookuptoPick{
Public String AddressId{Get;Set;}

public list<selectOption> getPickAccountVals(){
            list<selectOption> options  = New List<selectOption>();
            options.add(new selectOption('' , '-- None --'));
            for(Clinical_Address_Association__c claddr: [Select id,name from Clinical_Address_Association__c]){
                options.add(new selectoption(claddr.id,claddr.name));
            }
            system.debug('Options |' + options);
        return options;
    }
 Public void save(){
  // Insert Object Here 
 }

}


@VF PAge
<apex:pageBlockSectionItem dataStyle="width:1%" labelStyle="width:1%" >
   <apex:outputLabel >Address Id</apex:outputLabel>
    <apex:selectList size="1" value="{!AddressId}" label="Address ID" multiselect="false" style="width:180px">
         <apex:selectOptions value="{!PickAccountVals}" ></apex:selectOptions>
    </apex:selectList>
</apex:pageBlockSectionItem>

1. Getting AddressId by {Get;set;}
2. Then how can i save this object.

Thanks in advance !!

Regards,
Soundar P
 
Dear Developers,

I would like to send notification of public group users by using batch class(weekly based). can anyone please advise me how can i change my code for accurate requirement.

Batch Class 
global class PSO_etmfErrorLogBatch implements database.batchable<SObject>{

global database.querylocator start(database.batchableContext bc){
    system.debug('Start Method Running');
    return Database.getQueryLocator('Select Id,name from eTMF_Files_Error_Log__c');
}

global void execute(database.batchableContext bc, List<eTMF_Files_Error_Log__c> errlogList){
    system.debug('Execute Method Running');
    List<String> toAddresses = new List<String>();
    List<User> userList = [select id, name, email, isactive, profile.name, userrole.name, usertype 
                           from user 
                           where id in (select userorgroupid from groupmember where group.name = 'Document Tracking Admin')];
    for(User u : userList){           
        toAddresses.add(u.email);
    }  
    List < Messaging.SingleEmailMessage > emails = new List < Messaging.SingleEmailMessage > ();
    for (eTMF_Files_Error_Log__c irow_erLog : errlogList) {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setToAddresses(toAddresses});
        email.setSubject('Last Week ETMF Error Log'); 
        email.setPlainTextBody('Dear user, Please Check Last Week ETMF Error Log');
        emails.add(email);
    }
    Messaging.sendEmail(emails);
}

global void finish(database.batchableContext bc){}

}

Hearty Thanks In Advance !!

Regards,
Soundar P
Dears,

Can Anyone give me a good solution !!

Example:- 

Person A and Person B Working in Same company , Person A Will not continue his job hereafter. Suddenly he leaves his job without give any information. So Person B need to handle him record as well. How it's Possible ???

1. Person A Using Different Profile .

2. Person A Records OWD is Private.

3. How person B can access that records ???


Thanks In Advance !

Regards,
Soundar P
Dears,

I need to display an amount in table <Td> (calculating With Percentage - This value also available <td> in same row <tr>).

Step 1 : Enter An Amount  (Example : 1000)

Step2  : Entered Amound need to Calculate with Percentage (Example : 10%  (10/100) * 1000)

Step 3 :  Calculated Amount should be display in another <Td>.

User-added image
 
Controller 
---------------------------------------------------------------------------
public with sharing class WholeSale_User_Stories{
    
    Public Account acc {get;set;}
    Public Integer EnteredAmount{get;set;}
    //Public Integer secondNumber{get;set;}
    Public Integer result{get;set;}
    Public List<Exposure_Limit_WS__c> expLimitList{get;Set;}
    
    public WholeSale_User_Stories(ApexPages.StandardSetController controller) {
    }
    
    public WholeSale_User_Stories()
    {
        expLimitList = [Select id,name ,Particulars__c,Standard_Limit_Percentage__c From Exposure_Limit_WS__c];
        acc = New Account();
        
        /*for(Exposure_Limit_WS__c expLimit : expLimitList){
stanPer = expLimit.Standard_Limit_Percentage__c;

}*/
    }
    
    Public PageReference init(){
        EnteredAmount = 0;
        //secondNumber = 0;
        result = 0;
        return Null;
    }
    
    Public PageReference doSum(){
        EnteredAmount= EnteredAmount== Null ? 0 : EnteredAmount; 
        //secondNumber = secondNumber == Null ? 0 : secondNumber; 
        System.debug('************Entered Amount ' + EnteredAmount);
        result = EnteredAmount; //test
        System.debug('############result | ' + result);
        return Null;
    }
        
    //Wrapper Class
    
    /*Public Class WholeSaleWrapper{

Public double StandardLimitPercent;

public WholeSaleWrapper(Exposure_Limit_WS__c exp){
StandardLimitPercent = exp.Standard_Limit_Percentage__c;
}

}*/
  
}
 
VF Page
--------------------------------------------------------------------
<apex:page sidebar="False" showHeader="False"  controller="WholeSale_User_Stories">
<apex:form id="frm">
  <html>
  <head>
  
  <!-- Bootstrap Online Link -->
  <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous" />
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  
  <style>
  
  </style>
  </head>
  <body>
   
  <div><br/><br/><br/><br/></div>
  <div class="container">
  <div class="row col-sm-12" align="center">
  <div class="form-group col-sm-6" align="right">
  <apex:outputLabel >Selected Borrower &nbsp;&nbsp;&nbsp;</apex:outputLabel> 
  <apex:inputField value="{!acc.Parentid}"/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </div>
  <div class="form-group col-sm-4" >
  <apex:outputLabel for="theTextInput1">Enter Amount &nbsp;&nbsp;&nbsp;</apex:outputLabel> <apex:inputText value="{!EnteredAmount}" id="theTextInput1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <!--<apex:outputlabel  value="Result Is : {!result}" for="theTextInput2"></apex:outputlabel >  -->
  </div>
  <div class="form-group col-sm-2" align="left">
<!--  <button type="button" class="btn btn-info" styleClass="buttonStyle" style="background:#388A9D" >Calculate</button> -->
<apex:commandButton action="{!doSum}" value="Calculate" style="background:#52D7F5"/>
  </div>
 <br/>  <br/>
  </div>
         
  <table border="1" width="100%">
  <!--<tr>
  <td colsapn="6">Owned Funds Amount INR</td>
  <td width="10%"></td>
  <td width="10%"></td>
  </tr> -->
  
  <tr bgcolor="#DAF3FC" style="font-weight:bold">
  <td rowspan="2" colspan="2" align="center">Particulars</td>
  <td width="10%" rowspan="2" align="center">Standard Limit in % for Loan Company</td>
  <td  colspan="2" align="center">Infrastructure Finance Company</td>
  <td  colspan="2" align="center"> AFC and LC (only for Infrastructure Loan and/ or Investment)</td>
  <td width="17%" align="center" rowspan="2">Exposure Limits in Amount INR</td>
  <td align="center" rowspan="2">Exposure Limits in Amount INR ( For Non PPP projects and PPP projects Non Tripartite cases)</td>
  
  </tr>
  
  <tr bgcolor="#DAF3FC" style="font-weight:bold">
  <td width="11%" align="center">Additional limit %</td>
  <td width="11%" align="center">Total Limit %</td>
  <td width="10%" align="center">Additional limit ***</td>
  <td width="12%" align="center">Total Limit</td>
  </tr>
  
  <apex:repeat value="{!expLimitList}" var="whlsl">
  <tr>
  <td width="7%" align="center"><apex:outputText value="{!whlsl.Particulars__c}" ></apex:outputText></td>
  <td width="9%" align="center"><apex:outputText value="{!whlsl.Name}"></apex:outputText> </td>
  <td Align="center"><apex:outputText value="{!whlsl.Standard_Limit_Percentage__c}"  ></apex:outputText>%</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td bgcolor="#E6F4C8" align="center">{!result}</td>
  <td bgcolor="#E6F4C8" align="center">--</td>
  </tr>
  </apex:repeat>
 
  </table>
  
  </div> <!-- Container Closed -->
  </body>
  </html>
  </apex:form>
  </apex:page>

Thanks In Advance.

Regards,
Soundar.
 
Hi All,

Once doubt i have.. if while creating a lead fro  web to lead . if i have checked default lead owner box in lead setting, but i have not mentioned the user or queue in it.. so who will be the default owner for the lead?

Regards
Pranav Shah
 
Hi Guys,
 i have one agreement objcet , in this object some records will be there, in these records i want to select one primary record...
please help on this.. below is my code ..
<apex:page standardController="Apttus__APTS_Agreement__c" extensions="OnLoadController">
<apex:form >

        <apex:outputText value="{!Apttus__APTS_Agreement__c.Name}" rendered="false"/>
        <apex:outputText value="{!Apttus__APTS_Agreement__c.Apttus__Account__c}" rendered="false"/>
      
        <apex:outputText value="{!Apttus__APTS_Agreement__c.APTS_Primary__c}" rendered="false"/>

 <apex:commandButton id="btnOnLoad" action="{!onLoad}" value="On Load" style="display: none" />
        
        <script>
            var btnOnLoad = document.getElementById("{!$Component.btnOnLoad}");
        </script>
        
        <apex:pageBlock mode="edit" rendered="{!hasErrors}" >
            <apex:pageMessages />
            <apex:pageBlockButtons location="bottom" >
                    <apex:commandButton action="{!doMakePrimary}" value="Make Primary"/>  
                <apex:commandButton action="{!doCancel}" value="{!$Label.apttus__apts_agreement__cancel}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <script>
        // register to invoke the function after the page load
        var hasErrors = "{!hasErrors}";
        if (hasErrors.toLowerCase() == 'false') {
            window.onload = function() { 
                // on load
                btnOnLoad.click();
            };
        }
    </script>
    
</apex:page>

and Controller code...
 
public class OnLoadController {

    public Apttus__APTS_Agreement__c agreement { get; set; }

    public OnLoadController(ApexPages.StandardController stdController){
        this.agreement = (Apttus__APTS_Agreement__c)stdController.getRecord();
    }
    
    public void doMakePrimary(){
        Apttus__APTS_Agreement__c agreementRec = [SELECT ID, APTS_Primary__c, Apttus__Related_Opportunity__c FROM Apttus__APTS_Agreement__c WHERE ID =: agreement.Id];
        //add If condition to check other agreement records
        agreementRec.APTS_Primary__c = TRUE;
        insert agreementRec;
    }
    
    public PageReference doCancel() {
        PageReference agreementPage = new PageReference('/' + agreement.id);
        return agreementPage;
    }
    
    public String hasErrors { get; set; }

    public PageReference onLoad() {
             update agreement;
        return null;
    }


}

Thanks In Advance... 
HI,

I like to update a Queue Owner ,

1. Display all queue's in visualforce page
2. select a Queue by dropdown 
3. Update current owner by click save button.


Can anyone explain how i can achieve this Process.

Thanks,
Soundar. 
How can we display a visualforce page in child tab by a (Detail Page) button click.

Regards,
Soundar.
HI,

I can't get the CaseID from Case activity based on the condition. Can Anyone please check and let me know how can i solve this problem.

Trigger
/* 
Name          : BusinesStatusAndStatusUpdate
Description   : Update Receive Document , Receive & Track Credit Balance, Contact Provider, Confirm Credit Balance,Verify Provider Billing Issues And Create a New Case
Created By    : OrbitTeam_Soundar
Created Date  : 08/11/2017 
*/

trigger BusinesStatusAndStatusUpdate on Case_Activity__c (After Update) {
    Set<Id> caseId = New Set<Id>();
    List<Case_Activity__c> casActList = New List<Case_Activity__c>();
    List<Case_Activity__c> Up_casActList = New List<Case_Activity__c>();
    //For Getting a record Type
    Id creditbalreportId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive And Track Credit Balance').getRecordTypeId();
    System.debug('Credit Balance Report recordType name |' + creditbalreportId );
    string ownerId =''; 
    For(Case_Activity__c ca : Trigger.New){
        system.debug('Checking for CaseId ');
        If(ca.Case__c != Null && ca.RecordtypeId == creditbalreportId && ca.Activity_Business_Status__c == 'Credit Balance Reported' 
        && ca.Case__r.Type=='Credit – Balance Recoupment'){
            ownerId  = ca.Case__r.OwnerId;
            caseId.add(ca.Case__c);
            System.debug('Case ID | ' + caseId);
        }
    }
    
    Id receiveDocId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive Document').getRecordTypeId();
    System.debug('receive doc Rec |' + receiveDocId );
    Id ContProviderId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Contact Provider').getRecordTypeId();
    System.debug('Contact Provider Rec |' + ContProviderId );
    Id ConCredBalId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Confirm Credit Balance').getRecordTypeId();
    System.debug('Credit Balance Rec |' + ConCredBalId );
    Id BillIssueId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Verify Provider Billing Issues').getRecordTypeId();
    System.debug('Billing Issue Rec |' + BillIssueId );
    
    list<id> st_RecTyId = new list<id>();
    st_RecTyId.add(creditbalreportId);
    st_RecTyId.add(receiveDocId);
    st_RecTyId.add(ContProviderId);
    st_RecTyId.add(ConCredBalId);
    st_RecTyId.add(BillIssueId);
    
    List<Case_Activity__c> caActList = [Select id,Name, Case__c,Activity_Business_Status__c,Status__c  from Case_Activity__c Where Case__c  =:CaseId AND RecordTypeId IN: st_RecTyId];
    
    for(Case_Activity__c cAct : caActList){
        If(cAct.Activity_Business_Status__c != 'Activity Not Applicable'){
            cAct.Activity_Business_Status__c = 'Activity Not Applicable';
        }
        if(cAct.Status__c != 'Completed'){
            cAct.Status__c = 'Completed';
        }
        Up_casActList.add(cAct);
    }

    
    System.debug('casActList Size | ' + casActList.size());
    If(Up_casActList.size() > 0){
        Update Up_casActList;
        Case cs = new Case();
        cs.Case_Name__c= 'Provider Audit - Onsite';
        cs.Type='Provider Audit - Onsite';
        cs.OwnerId = ownerId;
        insert cs;
    }

}

Thanks In Advance.

Soundar.

Hi ,

I am getting below Error when i am trying to update a "Contact Name" in Case Object (In After Insert). 

Error  : PrimaryAssociateType: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id 5001F000000w4LpQAI; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.PrimaryAssociateType: line 60, column 1

My Trigger

trigger PrimaryAssociateType on Case_Associate__c (Before Insert, After Insert) {
    
    Set<Id> caseId = New Set<Id>();
    set<Id> caseId1 = New Set<Id>();
    List<case> updtCon = New List<case>();
    Map<Id,Case_Associate__c> casMap  = New Map<Id,Case_Associate__c>(); 
    
    if(Trigger.isBefore && Trigger.isInsert){
        For(Case_Associate__c  ca : Trigger.New){
            If(ca.Case_Number__c != Null){
                CaseId.add(ca.Case_Number__c);
                System.debug('Case Number | ' + CaseId);
            }
        }
        
        IF(CaseId.size() > 0){
            List<Case_Associate__c> cas = [Select id,name,Case_Number__c,Associate_Type__c from Case_Associate__c Where Case_Number__c =:CaseId AND Associate_Type__c = 'Primary'];
            System.debug('Case Associate Type With Primary |' + cas);
            System.debug('Size Of Primary | ' + cas.Size());
            Case_Associate__c cast1 = New Case_Associate__c();
            String curPage = ApexPages.currentPage().getUrl();
            IF(cas.Size() > 0 && curPage.contains('Primary')){
                System.debug('Primary is Already Created');
                for(Case_Associate__c  cas1 : Trigger.New){
                    cas1.addError('Primary Associate Type was Already Created. So Please Choose "Secondary" or "Other" ');
                } 
            } else {
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Case Associate Created Successfully'));
                System.debug('Secondary || Other');
            }
        }
    }
    
    if(Trigger.isAfter && Trigger.isInsert){  
        For(Case_Associate__c ca1 : Trigger.New){
            IF(ca1.Case_Number__c != Null && ca1.Entity_Type__c == 'Provider' && ca1.Associate_Type__c == 'Primary'){
                caseId1.add(ca1.Case_Number__c);
                casMap.put(ca1.Case_Number__c,ca1);
                System.debug('Case Number 1 | ' + caseId1);
            }
        } 
        
        System.debug('caseId1.size() | ' + caseId1.size());
        IF(caseId1.size() > 0){
            for(string irow : casMap.keyset()){
                Case c = New Case(id=irow);
                System.debug('&&&&&&& irow |'+ irow);
                c.ContactId = casMap.get(irow).Entity1__c;
                system.debug('Contact Id |' + c.ContactId);
                updtCon.add(c);
            }
            System.debug('&&&&&&&&&  Size Of updtCon |' + updtCon.size());
            If(updtCon.size() > 0){
                Insert updtcon;
            }
        }
    }
}
Regards,
Soundar.
Hi , 

I am trying to display a error message in vf page based on below condition.

1. Case assignment is related list in case . 
2. There is one picklist field in case assignment object.values are primary, secondary and other.
3. We can create a record with primary at only one time. 
4. It should be showing error message whenever trying to create a record with primary again.

can anyone please advise me ... how can I achieve this working flow ...


regards, 
soundar.
Hi Friends,

I am Trying to cover a test class for below Trigger , It's covered with 60%. Can anyone please help to cover upto 100%

@Trigger
/*
        Description: Update Preferred Price & Least Price in Indent Object
        Owner: Thabi
        Date: 17-Sep-13
        Test Class: TestOI_Indent_Creation
*/
trigger OI_UpdateIndentPrice on RawMaterial__c (after update) {
    map<id, RawMaterial__c> mapRm = new map<id,RawMaterial__c>(); 
    list<Indent__c> lstupdateindent = new list<Indent__c>();

    for(RawMaterial__c irow: trigger.new){
        if( irow.Preferred_Vendor__c != null || irow.Least_Vendor__c != null){
            mapRm.put(irow.id,irow);
        }
    }

    List<Indent__c> lstIndent = [select id, Raw_Material__c, PV_Rm_Cost__c from Indent__c
                                  where Raw_Material__c IN:mapRm.keyset() AND Product__c != NULL];
    
    if(lstIndent.size()>0){
        for(Indent__c krow : lstIndent){
            //Below Lines are not covered
            if(mapRm.containskey(krow.Raw_Material__c)){
                krow.PV_Rm_Cost__c = mapRm.get(krow.Raw_Material__c).Preferred_Price__c;
                krow.LV_Rm_Cost__c = mapRm.get(krow.Raw_Material__c).Least_Price__c;  
                lstupdateindent.add(krow);      
            }  
        
        }
        
        update lstupdateindent;
    }

}


@Test Class - I covered almost 60%
 
@IsTest
Public Class OI_RollupMaterialCost_Test{

static testMethod void RollupMaterialCostTest(){

Product2 prod = New Product2();
prod.Name = 'Test Product';
prod.HSN_Code__c = 'Prod123';
prod.Total_Material_Cost__c = 50;
prod.Total_RM_Cost__c = 100;
insert prod;

Vendor__c vr = New Vendor__c();
vr.Name = 'Test Name';
insert vr;

Vendor__c vr1 = New Vendor__c();
vr.Name = 'Test Name1';
insert vr1;

RawMaterial__c rm = New RawMaterial__c();
rm.Name = 'Test_rawMaterials';
rm.Unit__c = 'Bag';
rm.Preferred_Vendor__c = vr.Id;
rm.Preferred_Price__c =10;
rm.Least_Price__c = 20;
rm.Least_Vendor__c  = vr1.Id;
insert rm;

Indent__c ind = New Indent__c();
ind.Measurement__c = 12;
ind.PV_Rm_Cost__c =rm.Preferred_Price__c;
ind.LV_Rm_Cost__c = rm.Least_Price__c ;
ind.Product__c = prod.Id;
ind.Raw_Material__c = rm.Id;
ind.PV_Rm_Cost__c = 26;
ind.LV_Rm_Cost__c = 36;
Insert ind;

ind.Measurement__c = 14;
ind.PV_Rm_Cost__c =rm.Preferred_Price__c;
ind.LV_Rm_Cost__c = rm.Least_Price__c ;
ind.Product__c = prod.Id;
ind.Raw_Material__c = rm.Id;
Update ind;
}

}

Thanks in advance !!

Regards,
Soundar. 

 
HI Friends,

I am using " ApexPages.Standard Controller "  in constructor , can anyone please explain how can i cover this line in test class. i am not able to create an instance for my class in the test class. please refer my following class and good advise me how can i cover this test class as well.
 
public class caseAssignment{
    //Variables
    Public Case_Associate__c str;
    public ApexPages.StandardController controller;
    Public String recType{get;set;}
    Private final Case_Associate__c caseSense;
    Public Boolean section;
    
    //Constructor | Passing Case Number Into case Associate
    public caseAssignment(ApexPages.StandardController controller) {
        this.caseSense = (Case_Associate__c)controller.getRecord();
        caseSense.Case_Number__c = ApexPages.currentPage().getParameters().get('C_A_ID');
       // caseSense.OwnerId = ApexPages.currentPage().getParameters().get('Own');
        system.debug('recType ***** |' + recType);
    }
    
    public PageReference test() {
        return null;
    }
    
    //Get Record Type & Display in VF Pages
    public List<SelectOption> GetRecordTypes() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('--None--','--None--'));
        for(RecordType sRecordType : [SELECT Id, Name FROM RecordType WHERE sObjectType = 'Case_Associate__c'])
        {
            options.add(new SelectOption(sRecordType.Id, sRecordType.Name));
        }
        system.debug('Options | ' + options);
        return options;
    }

    //Update Record Type
    Public void updateRecordType(){
        system.debug('*******  Starting ******');
        caseSense.recordTypeId = recType;
        System.debug(' ***recordTypeId *** ' + recType + '|' +  caseSense.recordTypeId);
        system.debug('recType ***** |' + recType);
    }
    
    
}

Thanks In Advance ...

Regards,
Soundar.​
Hi everyone,
I am learning SF....And now i am at the stage where i have been given a assignment and it says:
1)Need to fetch all the Account records on my VF Page...
2)I have written the Query as : Select AccountNumber,Account.Name From Account...
3) I have created a VF Page and also binded it with custom Controller...
4) Now i want to fetch the AccountNumber and AccountName on the VFPage...How should i write my program on VFPage as well as Controller.....

I tried doing it myself, didn't work up to the expectation..
Any suggestions would be valuable..

VFPage
User-added image
ControllerPage
User-added image
I have a two picklist values.
1.Country  2.State
if i select the india then the  state picklist shoud have states belongs to india.Like that Us also

Can Any one help me.If possible provide the code

Thanks