• Prem Chauhan
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 26
    Replies
Hello SFDC Experts!

Please guide me that, how to calculate the difference between first and second task created Date &Time and against the single lead salesforce  

I have created 1 field in Lead Object Named as "Lead Difference DateTime" and I want to update this field by calculating the difference between first and second task created Date &Time against that taged lead. 

Thanks in Advance. 
How to get the details of the custom object's(Audit) related list(Activities) detail in the Report (report type is Audit report). 
 
Audit data capturing in Audit object. and in the Audit objects, related List contains Activities In Activities the lead and Account has got tagged. 
When I created a report on Audit object I couldn't able to get the detail of Lead anywhere, although I tried by creating report type it's not showing.
There is no such relationships exist. In Audit objects except for User lookup 
Please read again to understand. 

NOTE: I want the Lead/Account Name in the report (Just to track, this Audit belongs to which Lead/Account/Opportunity)

Please help me quickly as it's very urgent. 
Hi Everyone,

Let me know the solution please: How to upload an image through Visualforce page and store in salesforce custom object and display in Custom object detail page. 

It's urgent.  
Note: When users fill all the data with an Image after a click on the save button then all those details and including inserted image should get save first and then display in that custom object detail page.  


Many thanks in advance. 
Following is my requirement Please Help Me. 
I want to write an Apex Trigger based on Particular Role Hierarchy (XYZ is my role Name).  If the users are not blank in XYZ Role then fetch those users and add the same users in ABC object's field User(This is a custom picklist field of ABC object). 

Can anyone help me to achieve this  Many Thanks in advance. 

if we add/delete/Update user in XYZ roles then same will reflect on the ABC objects picklist fields named as User. 
syntax to accept only 10 digit number in inputText Field and should't contain any character please help me with this (Without Javascript)              
My SOQL: [SELECT ID,Name, Status FROM Lead WHERE CreatedDateNotEqualToLastModified__c = TRUE AND LastModifiedDate >= LAST_N_DAYS:2];

Can anyone help with this URGENT?????
Object: Lead/Account 
SOQL is not working can anyone help me. 
My Query: [SELECT ID, Name FROM LEAD WHERE CreatedDate != LastModifiedDate ];

Error:  Unknown error parsing query
Installed Unmanaged package: Inline Account Hierarchy


/**  Copyright (c) 2008, Matthew Friend, Sales Engineering, Salesforce.com Inc.
*  All rights reserved.
*
*  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
*  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*  Neither the name of the salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
*  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
*  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

/**
* To adapt this to anouther Object simply search for "Change" to go to the places 
* where the sObject and query must be changed
*/
public with sharing class AccountStructure{

    //Declare variables
    public String currentId;
    public List<ObjectStructureMap> asm ;
    public Map<String, ObjectStructureMap> masm;
    public List<Integer> maxLevel;
    
    /**
    * Contructor
    */
    public AccountStructure() {
        this.asm = new List<ObjectStructureMap>{};
        this.masm = new Map<String, ObjectStructureMap>{};
        this.maxLevel = new List<Integer>{};
    }
    
    /**
    * Allow page to set the current ID
    */
    public void setcurrentId( String cid ){
        currentId = cid;
    }

    /**
    * Return ObjectStructureMap to page
    * @return asm
    */
    public List<ObjectStructureMap> getObjectStructure(){
        asm.clear();
        if ( currentId == null ) {
            currentId = System.currentPageReference().getParameters().get( 'id' );
        }
        
        System.assertNotEquals( currentId, null, 'sObject ID must be provided' );
        asm = formatObjectStructure( CurrentId );
        
        return asm;
    }

    /**
    * Query Account from top down to build the ObjectStructureMap
    * @param currentId
    * @return asm
    */
    public ObjectStructureMap[] formatObjectStructure( String currentId ){
    
        List<ObjectStructureMap> asm = new List<ObjectStructureMap>{};
        masm.clear();

        //Change below
        List<Account> al            = new List<Account>{};
        List<ID> currentParent      = new List<ID>{};
        Map<ID, String> nodeList    = new Map<ID, String>{};
        List<String> nodeSortList   = new List<String>{};
        List<Boolean> levelFlag     = new List<Boolean>{};
        List<Boolean> closeFlag     = new List<Boolean>{};
        String nodeId               = '0';
        String nodeType             = 'child';
        Integer count               = 0;
        Integer level               = 0;
        Boolean endOfStructure      = false;
        
        //Find highest level obejct in the structure
        currentParent.add( GetTopElement( currentId ) );

        //Loop though all children
        while ( !endOfStructure ){

            if( level == 0 ){
                //Change below     
                al = [ SELECT a.Type, a.Site, a.ParentId, a.OwnerId, a.Name, a.Industry, a.BillingCity , a.BillingState, a.Owner.Name, a.Id FROM Account a WHERE a.id IN : CurrentParent ORDER BY a.Name ];
            } 
            else {
                //Change below      
                al = [ SELECT a.Type, a.Site, a.ParentId, a.OwnerId, a.Name, a.Industry, a.BillingCity, a.BillingState, a.Owner.Name, a.Id FROM Account a WHERE a.ParentID IN : CurrentParent ORDER BY a.Name ];
            }

            if( al.size() == 0 ){
                endOfStructure = true;
            }
            else{
                currentParent.clear();
                for ( Integer i = 0 ; i < al.size(); i++ ){
                    //Change below
                    Account a = al[i];
                    nodeId = ( level > 0 ) ? NodeList.get( a.ParentId )+'.'+String.valueOf( i ) : String.valueOf( i );
                    masm.put( NodeID, new ObjectStructureMap( nodeID, levelFlag, closeFlag, nodeType, false, false, a ) );
                    currentParent.add( a.id );
                    nodeList.put( a.id,nodeId );
                    nodeSortList.add( nodeId );
                }
                
                maxLevel.add( level );                
                level++;
            }
        }
        
        //Account structure must now be formatted
        NodeSortList.sort();
        for( Integer i = 0; i < NodeSortList.size(); i++ ){
            List<String> pnl = new List<String> {};
            List<String> cnl = new List<String> {};
            List<String> nnl = new List<String> {};
            
            if ( i > 0 ){
                String pn   = NodeSortList[i-1];
                pnl         = pn.split( '\\.', -1 );
            }

            String cn   = NodeSortList[i];
            cnl         = cn.split( '\\.', -1 );

            if( i < NodeSortList.size()-1 ){
                String nn = NodeSortList[i+1];
                nnl = nn.split( '\\.', -1 );
            }
            
            ObjectStructureMap tasm = masm.get( cn );
            if ( cnl.size() < nnl.size() ){
                //Parent
                tasm.nodeType = ( isLastNode( cnl ) ) ? 'parent_end' : 'parent';
            }
            else if( cnl.size() > nnl.size() ){
                tasm.nodeType   = 'child_end';
                tasm.closeFlag  = setcloseFlag( cnl, nnl, tasm.nodeType );
            }
            else{
                tasm.nodeType = 'child';
            }
            
            tasm.levelFlag = setlevelFlag( cnl, tasm.nodeType ); 
            
            //Change below
            if ( tasm.account.id == currentId ) {
                tasm.currentNode = true;
            }
            asm.add( tasm );
        }
        
        asm[0].nodeType             = 'start';
        asm[asm.size()-1].nodeType  = 'end';
        
        return asm;
    }
    
    /**
    * Determin parent elements relationship to current element
    * @return flagList
    */
    public List<Boolean> setlevelFlag( List<String> nodeElements, String nodeType ){
        
        List<Boolean> flagList = new List<Boolean>{};
        String searchNode   = '';
        String workNode     = '';
        Integer cn          = 0;
        
        for( Integer i = 0; i < nodeElements.size() - 1; i++ ){
            cn = Integer.valueOf( nodeElements[i] );
            cn++;
            searchNode  = workNode + String.valueOf( cn );
            workNode    = workNode + nodeElements[i] + '.';
            if ( masm.containsKey( searchNode ) ){
                flagList.add( true );
            }
            else {
                flagList.add( false );
            }
        }
        
        return flagList;
    }
    
    /**
    * Determin if the element is a closing element
    * @return flagList
    */
    public List<Boolean> setcloseFlag( List<String> cnl, List<String> nnl, String nodeType ){
        
        List<Boolean> flagList = new List<Boolean>{};
        String searchNode   = '';
        String workNode     = '';
        Integer cn          = 0;
        
        for( Integer i = nnl.size(); i < cnl.size(); i++ ){
            flagList.add( true );
        }
        
        return flagList;
    }
    
    /**
    * Determin if Element is the bottom node  
    * @return Boolean
    */
    public Boolean isLastNode( List<String> nodeElements ){
        
        String searchNode   = '';
        Integer cn          = 0;
        
        for( Integer i = 0; i < nodeElements.size(); i++ ){
            if ( i == nodeElements.size()-1 ){
                cn = Integer.valueOf( nodeElements[i] );
                cn++;
                searchNode = searchNode + String.valueOf( cn );
            }
            else {
                searchNode = searchNode + nodeElements[i] + '.';
            }
        }
        if ( masm.containsKey( searchNode ) ){
            return false;
        }
        else{
            return true;
        }
    }
    
    /**
    * Find the tom most element in Heirarchy  
    * @return objId
    */
    public String GetTopElement( String objId ){
        
        Boolean top = false;
        while ( !top ) {
            //Change below
            Account a = [ Select a.Id, a.ParentId From Account a where a.Id =: objId limit 1 ];
            
            if ( a.ParentID != null ) {
                objId = a.ParentID;
            }
            else {
                top = true;
            }
        }
        return objId ;
    }
    
    /**
    * Wrapper class
    */
    public with sharing class ObjectStructureMap{

        public String nodeId;
        public Boolean[] levelFlag = new Boolean[]{};
        public Boolean[] closeFlag = new Boolean[]{};
        public String nodeType;
        public Boolean currentNode;
        
        /**
        * @Change this to your sObject
        */
        public Account account;
        
        public String getnodeId() { return nodeId; }
        public Boolean[] getlevelFlag() { return levelFlag; }
        public Boolean[] getcloseFlag() { return closeFlag; }
        public String getnodeType() { return nodeType; }
        public Boolean getcurrentNode() { return currentNode; }


        /**
        * @Change this to your sObject
        */
        public Account getaccount() { return account; }
        
        public void setnodeId( String n ) { this.nodeId = n; }
        public void setlevelFlag( Boolean l ) { this.levelFlag.add(l); }
        public void setlcloseFlag( Boolean l ) { this.closeFlag.add(l); }
        public void setnodeType( String nt ) { this.nodeType = nt; }
        public void setcurrentNode( Boolean cn ) { this.currentNode = cn; }

        /**
        * @Change this to your sObject
        */
        public void setaccount( Account a ) { this.account = a; }

        /**
        * @Change the parameters to your sObject
        */
        public ObjectStructureMap( String nodeId, Boolean[] levelFlag,Boolean[] closeFlag , String nodeType, Boolean lastNode, Boolean currentNode, Account a ){
            
            this.nodeId         = nodeId;
            this.levelFlag      = levelFlag; 
            this.closeFlag      = closeFlag;
            this.nodeType       = nodeType;
            this.currentNode    = currentNode;

            //Change this to your sObject  
            this.account = a;
        }
    }
}
My requirement is 

I need to show the Account hierarchy in custom vf page as same as standard like

In Account object, we have created on the field which is existing Account (lookUp).
if any Account is linked with this account then we need to show the All child account linked to that particular acc in VF page.
Account Name(Parent Account)    Type(Child Account)   Account Owner(Child Acc Owner)
TRTest                                            Industry                      prem
TrTest1                                           other                           karan 
And finally I want to add this page on Account Layout that user can see his/her Linked Account Hierarchy Wise..

Need Urgent Help...

 

how to reference user lookup field ID on account from contact in the Batch Apex

Object: Account 
Field:  1:- field A 2:- field B  

Object: Contact
Field:   Contact: Field C

When entering in Field A then Field B  will get Automatically update as Field A
Then in Contact Object which is related to This Account 
Then Field C will also get Update as Field A  
When I run the batch. 

Example:
Account Name = Test1   
Field A  = Test 
Field B  = Test   (Same as Field A)
Inserted Contact Related to Test1 Account  
Contact Field: Field C  = Test 


Many Thanks :) 
 

Need Urgent Help,

Actually, the scenario is I have a currency field in Account as well as in Opportunity.
and Account is mapped with Opportunity.

whenever my account selects the Currency Record type as  USD then the Account's currency fields (ABC__c) = $1000.00 shows a value correct.

but while creating the opportunity I'll select this account as a lookup. and some fields are already mapped.
but such scenario my opportunity's  Currency Record type is UAE when I save my opportunity than the value of account's Field (ABC__c) doesn't get converted.
Still, it shows a value of $1000 didn't get converted to UAE 


Please HELP ME FROM THIS SITUATION.

Many Thanks in Advance.
 

how to convert decimal numbers like (1234.12) to words in salesforce??

I need an output like this...

1234.12 = one thousand two hundred thirty-four. twelve paise (INR)
 I am getting this much of output 'one thousand two hundred thirty-four' but not getting how to append that "twelve paise" after the decimal point. 

Thanks in Advance...  
how to update only 1 parent records field from its child record field using 2 custom Labels [ 1:-Parent_Field_Label ,  2 :- Child_Field_Label]
below is my Trigger in that is is working fine .. But my requirement is that i want to use custom labels insted of Custom fields 
 
​trigger Job_Applic_To_Update_Hobbies_and_Interests on Job_Application__c  (after insert,after update) {
  
    Set<Id> positionIds = new Set<Id>();
    for(Job_Application__c objJobApp : Trigger.new)    {
        if(objJobApp.Hobbies_and_interests__c != ''){
            positionIds.add(objJobApp.Position__c);
            
        }
        map<id, Position__c> positionEntries = new Map<Id, Position__c>(
            [SELECT id,name,Hobbies_and_Interests__c FROM Position__c WHERE id IN : positionIds]
        );
        
        for(Job_Application__c objJobApp1 : Trigger.new)    {
            Position__c objPosition = positionEntries.get(objJobApp1.Position__c);
            if(objPosition !=null){
                objPosition.Hobbies_and_Interests__c = objJobApp1.Hobbies_and_interests__c;
                          } 
            update objPosition;
        }
    }
}

Please Any one help me How to write Code For this or any tips regarding custom labels name..
may be in future i may change the fields name but the functionality should work same i need not to change my code for changing my fields..


HOPE YOU GOT MY REQUIREMENT HELP ME SOON...
Thanks In Advance
PREM
trigger Job_Posting_Trigger_To_Update_Position_Fields on Job_Posting__c (after insert, after delete, after update) {   
 
//These 4 are my customn fields on my Custom object Position__c 
 //here Job_Posting__c  is the junction Object between " Position__c And Employment_Website__c "
 
    Decimal totPrice = 0;
    Decimal TotalBudget = 0;
    Decimal Totalpost = 0;
    Decimal max = 0;
    Decimal min = 0;
    
    
    List<Position__c> lstOfposupdate = new List<Position__c>();
    //Position__c objPosition = new Position__c();
    // Set<string> SetofOfEmployeeWebSiteIds = new Set<String>();
    
    Set<string> SetOfJobPosting = new Set<String>();
    // List<string> LstOfpostIds = new List<String>();
    
    List<Job_Posting__c> lstForJobPosting = new List<Job_Posting__c>();
    List<Job_Posting__c> lstForJobPostingMax = new List<Job_Posting__c>();
    List<Job_Posting__c> lstForJobPostingMin = new List<Job_Posting__c>();
    
    // List<Employment_Website__c> lstForEmpWeb = new List<Employment_Website__c>();
    string posIdToSet = '';
    
     List<Job_Posting__c > allbulkdata = trigger.isdelete ? trigger.old : trigger.new ;
       for(Job_Posting__c JobPostingObj : allbulkdata) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    
   /* if(Trigger.isInsert){ 
        for(Job_Posting__c JobPostingObj : Trigger.new) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    }
    
    if(Trigger.isDelete){ 
        for(Job_Posting__c JobPostingObj :Trigger.old) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    }
    
    if(Trigger.isUpdate){ 
        for(Job_Posting__c JobPostingObj : Trigger.old) {
            Job_Posting__c  objJobPostingOldVal = Trigger.oldMap.get(JobPostingObj.Id);
            SetOfJobPosting.add(JobPostingObj.Employment_Website__c);
            posIdToSet = JobPostingObj.Employment_Website__c;
        }
    }*/
    
    If(SetOfJobPosting.size()>0){
        
        lstForJobPosting = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                            Employment_Website__r.Maximum_Budget__c
                            from Job_Posting__c 
                            where Position__c IN:SetOfJobPosting] ;       
        
        lstForJobPostingMax = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                               Employment_Website__r.Maximum_Budget__c
                               from Job_Posting__c 
                               where Position__c IN:SetOfJobPosting
                               Order By Employment_Website__r.Price_Per_Post__c desc] ; 
        
        if(lstForJobPostingMax.size()>0){            
            max = lstForJobPostingMax[0].Employment_Website__r.Price_Per_Post__c;   
        }
        
        
        lstForJobPostingMin = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                               Employment_Website__r.Maximum_Budget__c
                               from Job_Posting__c 
                               where Position__c IN:SetOfJobPosting
                               Order By Employment_Website__r.Price_Per_Post__c Asc]; 
        
        if(lstForJobPostingMin.size()>0){            
            min = lstForJobPostingMin[0].Employment_Website__r.Price_Per_Post__c; 
        }
        
        for(String posId : SetOfJobPosting){   
            Totalpost = lstForJobPosting.size();
            for(Job_Posting__c jpObj : lstForJobPosting){ 
                
                if(posId == jpObj.Position__c){    
                    
                    totPrice = totPrice + jpObj.Employment_Website__r.Price_Per_Post__c ;
                    TotalBudget = jpObj.Employment_Website__r.Maximum_Budget__c + TotalBudget;                    
                }
            }
        }
        
        Position__c posUpdate = new Position__c();
        posUpdate.Id = posIdToSet;
        posUpdate.Total_Budget__c = TotalBudget;
        posUpdate.Total_Price_of_post__c = totPrice;
        posUpdate.Min_Price_of_Post__c = min ;
        posUpdate.Max_Price_of_Post__c = max;
        posUpdate.Total_Post__c = Totalpost;
        
        lstOfposupdate.add(posUpdate);
        
        if(lstOfposupdate.size()>0){
            update lstOfposupdate;
            System.debug('<==Updated succesfully==>');
        }
        
        
    }
}




User-added image
User-added image
When i click on new job Posting button it will ask me to select employment website when i select any one among multiple website then Price Per Post, Maximum Budget  is added Automatically, when i do update for inserted job posting records the fields on the position won't get update for that perticular position, Only related list is getting update for that perticular position.
In this case Update is not working..
[ There are totally 3 objects are there 1:jobPosting__c  2:  Employment_website__c 3 :Position__c ]


Thanks in Advance 

Prem Chauhan
syntax to accept only 10 digit number in inputText Field and should't contain any character please help me with this (Without Javascript)              
My SOQL: [SELECT ID,Name, Status FROM Lead WHERE CreatedDateNotEqualToLastModified__c = TRUE AND LastModifiedDate >= LAST_N_DAYS:2];

Can anyone help with this URGENT?????
Hi Team,

Requirement : I have created custom vf page for showing detailed record. Form here i have created custom clone button. I want to clone the record from detail page and i need to edit the fields as our own details (not existing record details) and create a new record.
How can we write additional vf page and controller class for cloning functionality.
Note : After clicking on clone button that page redirected to another page and show the record details, if i click on cancel button no need to create new record, until clicking on save button.

Please let me know any one , how can we achieve this functionality........


Thanks in Advance!....
Lakshmi.
 
I'm creating approval process in opportunity when engagement_model__c not equal to none which is a picklist field, an email should be sent to users.
im getting the email, but I'm not getting the link. I don't the issue. Help me to solve it.

Need Urgent Help,

Actually, the scenario is I have a currency field in Account as well as in Opportunity.
and Account is mapped with Opportunity.

whenever my account selects the Currency Record type as  USD then the Account's currency fields (ABC__c) = $1000.00 shows a value correct.

but while creating the opportunity I'll select this account as a lookup. and some fields are already mapped.
but such scenario my opportunity's  Currency Record type is UAE when I save my opportunity than the value of account's Field (ABC__c) doesn't get converted.
Still, it shows a value of $1000 didn't get converted to UAE 


Please HELP ME FROM THIS SITUATION.

Many Thanks in Advance.
 

trigger Job_Posting_Trigger_To_Update_Position_Fields on Job_Posting__c (after insert, after delete, after update) {   
 
//These 4 are my customn fields on my Custom object Position__c 
 //here Job_Posting__c  is the junction Object between " Position__c And Employment_Website__c "
 
    Decimal totPrice = 0;
    Decimal TotalBudget = 0;
    Decimal Totalpost = 0;
    Decimal max = 0;
    Decimal min = 0;
    
    
    List<Position__c> lstOfposupdate = new List<Position__c>();
    //Position__c objPosition = new Position__c();
    // Set<string> SetofOfEmployeeWebSiteIds = new Set<String>();
    
    Set<string> SetOfJobPosting = new Set<String>();
    // List<string> LstOfpostIds = new List<String>();
    
    List<Job_Posting__c> lstForJobPosting = new List<Job_Posting__c>();
    List<Job_Posting__c> lstForJobPostingMax = new List<Job_Posting__c>();
    List<Job_Posting__c> lstForJobPostingMin = new List<Job_Posting__c>();
    
    // List<Employment_Website__c> lstForEmpWeb = new List<Employment_Website__c>();
    string posIdToSet = '';
    
     List<Job_Posting__c > allbulkdata = trigger.isdelete ? trigger.old : trigger.new ;
       for(Job_Posting__c JobPostingObj : allbulkdata) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    
   /* if(Trigger.isInsert){ 
        for(Job_Posting__c JobPostingObj : Trigger.new) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    }
    
    if(Trigger.isDelete){ 
        for(Job_Posting__c JobPostingObj :Trigger.old) {
            SetOfJobPosting.add(JobPostingObj.Position__c);
            posIdToSet = JobPostingObj.Position__c;
        }
    }
    
    if(Trigger.isUpdate){ 
        for(Job_Posting__c JobPostingObj : Trigger.old) {
            Job_Posting__c  objJobPostingOldVal = Trigger.oldMap.get(JobPostingObj.Id);
            SetOfJobPosting.add(JobPostingObj.Employment_Website__c);
            posIdToSet = JobPostingObj.Employment_Website__c;
        }
    }*/
    
    If(SetOfJobPosting.size()>0){
        
        lstForJobPosting = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                            Employment_Website__r.Maximum_Budget__c
                            from Job_Posting__c 
                            where Position__c IN:SetOfJobPosting] ;       
        
        lstForJobPostingMax = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                               Employment_Website__r.Maximum_Budget__c
                               from Job_Posting__c 
                               where Position__c IN:SetOfJobPosting
                               Order By Employment_Website__r.Price_Per_Post__c desc] ; 
        
        if(lstForJobPostingMax.size()>0){            
            max = lstForJobPostingMax[0].Employment_Website__r.Price_Per_Post__c;   
        }
        
        
        lstForJobPostingMin = [select Id,Name,Position__c,Employment_Website__r.Price_Per_Post__c,
                               Employment_Website__r.Maximum_Budget__c
                               from Job_Posting__c 
                               where Position__c IN:SetOfJobPosting
                               Order By Employment_Website__r.Price_Per_Post__c Asc]; 
        
        if(lstForJobPostingMin.size()>0){            
            min = lstForJobPostingMin[0].Employment_Website__r.Price_Per_Post__c; 
        }
        
        for(String posId : SetOfJobPosting){   
            Totalpost = lstForJobPosting.size();
            for(Job_Posting__c jpObj : lstForJobPosting){ 
                
                if(posId == jpObj.Position__c){    
                    
                    totPrice = totPrice + jpObj.Employment_Website__r.Price_Per_Post__c ;
                    TotalBudget = jpObj.Employment_Website__r.Maximum_Budget__c + TotalBudget;                    
                }
            }
        }
        
        Position__c posUpdate = new Position__c();
        posUpdate.Id = posIdToSet;
        posUpdate.Total_Budget__c = TotalBudget;
        posUpdate.Total_Price_of_post__c = totPrice;
        posUpdate.Min_Price_of_Post__c = min ;
        posUpdate.Max_Price_of_Post__c = max;
        posUpdate.Total_Post__c = Totalpost;
        
        lstOfposupdate.add(posUpdate);
        
        if(lstOfposupdate.size()>0){
            update lstOfposupdate;
            System.debug('<==Updated succesfully==>');
        }
        
        
    }
}




User-added image
User-added image
When i click on new job Posting button it will ask me to select employment website when i select any one among multiple website then Price Per Post, Maximum Budget  is added Automatically, when i do update for inserted job posting records the fields on the position won't get update for that perticular position, Only related list is getting update for that perticular position.
In this case Update is not working..
[ There are totally 3 objects are there 1:jobPosting__c  2:  Employment_website__c 3 :Position__c ]


Thanks in Advance 

Prem Chauhan
1. salesprocess flow of execution
2.service clooud process flow of execution

 

Hi,

 

Integer i;

 

Public Integer i;

 

What is the difference between above two declaration.

i ran the below program in Apex  but i am getting error so please could you help me.

 

public  class SimpleArrayClass
{public static  integer findSum(Integer[]a)
{
Integer s=0;
for(integer x:a)
{s=s+x;
  }
 
 
return s;
}

  }

--------------------

 

@isTest
public class SimpleArrayTestClass
{
 @isTest Static Void sumTest()
{
Integer [] a=new Integer[4]{10,20,30,40};
integer act=0,exp=100;
act=SimpleArrayClass.findsum(a);
system.debug('Actual Value...' +act);
}
}

  • September 07, 2012
  • Like
  • 0

Hi all

 

what is difference between sales cloud and service cloud?

 I am Unable to understand 

 

Regards

 

Linganna

I have an apex:inputCheckBox, I'm trying to use the attribute value="{!ChkBoxVal}". In my custom controller, I declared Boolean ChkBoxVal - I tried to make it Public. I've looked around for some sample code, but failed. How do I declare it? How do I get it from page to page, like in the Wizard example?

Thanks,