• Pun!5h3r
  • NEWBIE
  • 15 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 16
    Replies
I want to create some query like:
SELECT ID, Name , dc__Contact__r.Account.Name, (SELECT ID, (select id from product2__r) From dc__Transaction_Line_Items__r) From dc__Transaction__c


I have to pass transaction object record as a parameter. How to Break down the query and accomplish it.
Note: I should get Transaction record which has fields of the child object dc__Transaction_Line_Items__r and sub child object Product__r
vf page
<apex:page controller="MatrixController" showHeader="false">

            <table style="height: 100%;width: 100%;background-color: snow;" >
                <tr>
                    <apex:repeat value="{!listHeader}" var="header">
                        <th style="width:25%;">
                            {!header}
                        </th>
                    </apex:repeat>
                </tr>
                <apex:repeat value="{!listMatrix}" var="Wrapper">
                    <tr>
                        <td>{!Wrapper.Name}</td>
                        <apex:repeat value="{!Wrapper.listOpportunity}" var="Opportunity">
                            <td>
                                <input type="text" pattern="[0-9]+" value="{!Opportunity.Amount}"/>
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>
            </table>
            <apex:form>
            <apex:CommandButton title="rahim"/>
            </apex:form>
</apex:page>
Controller
public class MatrixController {
    public List<Schema.PicklistEntry> lstMonth{get; set;}
    public List<Schema.PicklistEntry> lstType{get; set;}
    public List<String> listMonth{get; set;}
    public List<String> listType{get; set;}
    public List<String> listHeader{get; set;}
    public List<WrapperMatrix> listMatrix{get; set;}
    private List<Opportunity> listOpportunity;
    private Map<String,Opportunity> mapOpportunity;

    public MatrixController(){
        listMonth = new List<String>();
        listType = new List<String>();
        listHeader = new List<String>();
        listMatrix = new List<WrapperMatrix>();
        mapOpportunity = new Map<String,Opportunity>();
        Schema.DescribeFieldResult fieldResultMonth = Opportunity.Month__c.getDescribe();
        lstMonth = fieldResultMonth.getPicklistValues();
        fieldResultMonth  = Opportunity.Type__c.getDescribe();
        lstType= fieldResultMonth.getPicklistValues();

        for(Schema.PicklistEntry objPicklistEntry : lstMonth ){
            String strMonth = objPicklistEntry.getLabel();
            listMonth.add(strMonth);
        }

        for(Schema.PicklistEntry objPicklistEntry : lstType ){
            String strType = objPicklistEntry.getLabel();
            listType.add(strType);
        }

        listOpportunity = [SELECT Id, Month__c, Type__c, Amount FROM Opportunity WHERE Month__c != NULL ORDER BY Month__c, Type__c];
        
        for(Opportunity objOpportunity : listOpportunity) {
            mapOpportunity.put(objOpportunity.Month__c + ',' + objOpportunity.Type__c , objOpportunity);
        }

        system.debug(mapOpportunity);

        for(String strMonth : listMonth){
            WrapperMatrix objWrapperMatrix = new WrapperMatrix();
            objWrapperMatrix.Name = strMonth ;
            for(String strType : listType){
                if(mapOpportunity.ContainsKey(strMonth + ',' + strType)) {
                    objWrapperMatrix.listOpportunity.add(mapOpportunity.get(strMonth + ',' + strType));
                }
                else {
                    objWrapperMatrix.listOpportunity.add(new Opportunity());
                }
            }
            listMatrix.add(objWrapperMatrix);
        }

                system.debug(listMatrix);

        listHeader.add('Month/Type');
        for(String strHeader : listType) {
            listHeader.add(strHeader);
        }
    }

    public class WrapperMatrix{
        public String Name{get; set;}
        public List<Opportunity> listOpportunity{get; set;}
        public WrapperMatrix () {
            //Amount = (Integer)objOpportunity.Amount;
            listOpportunity = new List<Opportunity>();
        }
    }
}
in the above code i want to use commandButton, but to use commandButton we need to write it inside <form> tag .
as soon as i add form tag to vf. it gives following error
" System.SerializationException: Not Serializable: com/salesforce/api/fast/List$$lcom/salesforce/api/Schema/PicklistEntry$$r "

Thanks

 
Vf Page
<apex:page controller="MatrixController" showHeader="false">
            <apex:form>
            <table style="height: 100%;width: 100%;background-color: snow;" >
                <tr>
                    <apex:repeat value="{!listHeader}" var="header">
                        <th style="width:25%;">
                            {!header}
                        </th>
                    </apex:repeat>
                </tr>
                <apex:repeat value="{!listMatrix}" var="Wrapper">
                    <tr>
                        <td>{!Wrapper.Name}</td>
                        <apex:repeat value="{!Wrapper.listOpportunity}" var="Opportunity">
                            <td>
                                <input type="text" pattern="[0-9]+" value="{!Opportunity.Amount}"/>
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>
            </table>
            
            <apex:CommandButton title="rahim"/>
            </apex:form>
</apex:page>
Controller
public class MatrixController {
    public List<Schema.PicklistEntry> lstMonth{get; set;}
    public List<Schema.PicklistEntry> lstType{get; set;}
    public List<String> listMonth{get; set;}
    public List<String> listType{get; set;}
    public List<String> listHeader{get; set;}
    public List<WrapperMatrix> listMatrix{get; set;}
    private List<Opportunity> listOpportunity;
    private Map<String,Opportunity> mapOpportunity;

    public MatrixController(){
        listMonth = new List<String>();
        listType = new List<String>();
        listHeader = new List<String>();
        listMatrix = new List<WrapperMatrix>();
        mapOpportunity = new Map<String,Opportunity>();
        Schema.DescribeFieldResult fieldResultMonth = Opportunity.Month__c.getDescribe();
        lstMonth = fieldResultMonth.getPicklistValues();
        fieldResultMonth  = Opportunity.Type__c.getDescribe();
        lstType= fieldResultMonth.getPicklistValues();

        for(Schema.PicklistEntry objPicklistEntry : lstMonth ){
            String strMonth = objPicklistEntry.getLabel();
            listMonth.add(strMonth);
        }

        for(Schema.PicklistEntry objPicklistEntry : lstType ){
            String strType = objPicklistEntry.getLabel();
            listType.add(strType);
        }

        listOpportunity = [SELECT Id, Month__c, Type__c, Amount FROM Opportunity WHERE Month__c != NULL ORDER BY Month__c, Type__c];
        
        for(Opportunity objOpportunity : listOpportunity) {
            mapOpportunity.put(objOpportunity.Month__c + ',' + objOpportunity.Type__c , objOpportunity);
        }

        system.debug(mapOpportunity);

        for(String strMonth : listMonth){
            WrapperMatrix objWrapperMatrix = new WrapperMatrix();
            objWrapperMatrix.Name = strMonth ;
            for(String strType : listType){
                if(mapOpportunity.ContainsKey(strMonth + ',' + strType)) {
                    objWrapperMatrix.listOpportunity.add(mapOpportunity.get(strMonth + ',' + strType));
                }
                else {
                    objWrapperMatrix.listOpportunity.add(new Opportunity());
                }
            }
            listMatrix.add(objWrapperMatrix);
        }

                system.debug(listMatrix);

        listHeader.add('Month/Type');
        for(String strHeader : listType) {
            listHeader.add(strHeader);
        }
    }

    public class WrapperMatrix{
        public String Name{get; set;}
        public List<Opportunity> listOpportunity{get; set;}
        public WrapperMatrix () {
            //Amount = (Integer)objOpportunity.Amount;
            listOpportunity = new List<Opportunity>();
        }
    }
}
in the above code i want to use commandButton, but to use commandButton we need to write it inside <form> tag .
as soon as i add form tag to vf. it gives following error
" System.SerializationException: Not Serializable: com/salesforce/api/fast/List$$lcom/salesforce/api/Schema/PicklistEntry$$r "

Thanks

 
Hi,

How to detect whether a child record is deleted or not Using Process Builder and update its parent record using the same Process builder.

Thanks in Advance
Hi,

How to detect whether a child record is deleted or not Using Visual Flows  and update its parent record using the same Flows.

Thanks in Advance
I want to create some query like:
SELECT ID, Name , dc__Contact__r.Account.Name, (SELECT ID, (select id from product2__r) From dc__Transaction_Line_Items__r) From dc__Transaction__c


I have to pass transaction object record as a parameter. How to Break down the query and accomplish it.
Note: I should get Transaction record which has fields of the child object dc__Transaction_Line_Items__r and sub child object Product__r
in a picklist field there are two values value1 and value2. by selecting the values in picklist value1 will display fields text1,text2 and value 2 will display text3 and text4.how can achieve this ..
Hello,

there is Activities history on a custom object.
This has a standard button send email. But this button is not customizable.
Hence, i want to create a Visualforce page + Apex to overvide this custombutton.

My usecase:
There is a record of a custom object which have activity history. One of the field in them is Email__c, i wantt that when user clicks on the button it should automatically populate the email id of the current parent.

I am not concerned with populatig data, i will later see how to email it.

thank you for suggestion
  • May 30, 2016
  • Like
  • 0
Hi
My scenario is to update the checkbox field if the Address field in Account is update. After 30 second of the record saved, it should uncheck the checkbox field.

Can anyone help me out to solve this issue.
Trigger throwing an error "
trigger test on Account (before update) {
list<Account> a =  new list<Account>();
Account acc = [select Id,checkboxForPopUp__c,BillingAddress,BillingCity,BillingCountry,BillingCountryCode,BillingPostalCode,BillingState,BillingStateCode,BillingStreet
                         from Account
                         where Id =:trigger.new];
if( (acc!=Null) &&
((acc.BillingAddress != trigger.oldmap.get(acc.id).BillingAddress) || (acc.BillingCity != trigger.oldmap.get(acc.id).BillingCity) ||
(acc.BillingCountry != trigger.oldmap.get(acc.id).BillingCountry) || (acc.BillingStateCode != trigger.oldmap.get(acc.id).BillingStateCode) ||
(acc.BillingStreet != trigger.oldmap.get(acc.id).BillingStreet))  
)
{
acc.checkboxForPopUp__c = TRUE;
a.add(acc);
}
update acc;
}

execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 001Q00000104rDvIAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001Q00000104rDv) is currently in trigger test, therefore it cannot recursively update itself: []: Trigger.test: line 15, column 1"
Hi Everybody,

An opp object has stage field.As per my requirement if opporutnity stage field has not been changed for the last 20 days then I would like to inform an opporunity owner by sending him an email.

I am trying to use workflow.I want to capture the number of days an opp has stayed in a particular stage and if the number of days is equal to 20 days then workflow will send an email to the opp owner.

If i can capture the last time an opportunity stage has been changed in a field that would be nice.However,I am not able to do that ,Can somebody please help.


 
Hi, I have two customer fields in Custom Object:

- Representative - lookup to User object
 - Customer – lookup to Contacts object

Need to do that pair of Representative+Customer will be unique. I create unique text field and add workflow rules that any insert or update will add to text field by formula: Representative__r.Id & Customer.Id.
Every time when I add or edit record with the same Representative or Customer display error : 

"Error: Invalid Data. 
Review all error messages below to correct your data.
Duplicate value on record: TC-0032 (Related field: UniqueTextField)"
I no need that Representative wiil be unique or Customer separately. I need to a unique couple of these values.
How to fix it?
 
hello everyone
my query is : i have to write trigger on student object which has one custom checkbox if user check that checkbox then automatically deselect all in record and if user update that true to false than print error message that at least you have to select one check box....please help thanxs in advance
Hello!
I'm new to apex, please advise.
I have created the trigger that create child record based on parent field value. And I need to start this process avaery day at once for all records. So i write the batch process which search for all records where conditions are met, and set the checkbox to true if it does.
And the problem is when the batch process completes the trigger doesn't fire at all. In the Apex Jobs found error: Error Message
Below my trigger and batch processes:
Batch:
global class ITAssetProessingBatch implements Database.Batchable<sobject>{
  global String [] email = new String[] {'VBakanov@bcsprime.com'};
  
  //Start Method
  global Database.Querylocator start (Database.BatchableContext BC) {
    return Database.getQueryLocator('SELECT id, Name, FirstDateOfMonth__c, FrstDayOfMnth__c, Status__c FROM IT_Asset__c WHERE FirstDateOfMonth__c = today AND Status__c = \'Activated\' AND FrstDayOfMnth__c = false');//Query which will be determine the scope of Records fetching the same
  }

  //Execute method
  global void execute (Database.BatchableContext BC, List<sobject> scope) {
    List<IT_Asset__c> ITAList = new List<IT_Asset__c>();
    List<IT_Asset__c> updtaedITAList = new List<IT_Asset__c>();
    for (sObject objScope: scope) { 
        IT_Asset__c newObjScope = (IT_Asset__c)objScope ;
        newObjScope.FrstDayOfMnth__c = true;
        updtaedITAList.add(newObjScope);
        System.debug('Value of UpdatedITAList'+updtaedITAList);
    } 
        if (updtaedITAList != null && updtaedITAList.size()>0) {
            Database.update(updtaedITAList); System.debug('List Size '+updtaedITAList.size());
        }
  }
    
//Finish Method
  global void finish(Database.BatchableContext BC){
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

  //Below code will fetch the job Id
  AsyncApexJob a = [Select a.TotalJobItems, a.Status, a.NumberOfErrors, a.JobType, a.JobItemsProcessed, a.ExtendedStatus, a.CreatedById, a.CompletedDate From AsyncApexJob a WHERE id = :BC.getJobId()];//get the job Id
  System.debug('$$$ Jobid is'+BC.getJobId());

  //below code will send an email to User about the status
  mail.setToAddresses(email);
  mail.setReplyTo('VBakanov@bcsprime.com');
  mail.setSenderDisplayName('Apex Batch Processing Module');
  mail.setSubject('Batch Processing '+a.Status);
  mail.setPlainTextBody('The Batch Apex job processed  '+a.TotalJobItems+'batches with  '+a.NumberOfErrors+'failures'+'Job Item processed are'+a.JobItemsProcessed);
  Messaging.sendEmail(new Messaging.Singleemailmessage [] {mail});
  }
    //Scheduler Method to scedule the class
  global void execute(SchedulableContext sc)
    {
        ITAssetProessingBatch conInstance = new ITAssetProessingBatch();
        database.executebatch(conInstance,100);
    }
}
Trigger:
Trigger CashFlow on IT_Asset__c (after update)
{
         List<Cash_Flow__c> sub=new List<Cash_Flow__c>();
     for(IT_Asset__c it : Trigger.new)
     {
           if(it.FrstDayOfMnth__c == true)
           {
                   Cash_Flow__c cf=new Cash_Flow__c();
                   cf.CurrencyIsoCode=it.CurrencyIsoCode;
                   cf.Date__c=it.Start_Date__c;
               	   cf.RecordTypeId='012b0000000UOay';
                   cf.IT_Asset__c=it.Id;
                   //add other fields of subject here and add volunteer values in that.
                 
                   sub.add(cf);
            }
            if(sub.size()>0)
            insert sub;
     }
}

I deactivate the trigger and run batch and it completes without errors, so i think the problem in trigger.... Maybe I made something wrong?
 
In my current senarion

I want to trigger for   copying custom field    
accountspecification__c   value to another standard field  SicDesc   

in a same object (Account)  

Please help me.

Thanks In Advance
hi.. i have a custom object with a status field (picklist) having values completed and pending.. i want to create a pie chart which will display completed records vs total records(eg: i have 7 rec out of which 3 have status completed). which type of report should i use and what crieteria should i specify..