• pdvapor
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 14
    Replies

I have created a custom object (Product_Sales__c) that is related to Accounts and when I try to create a custom list button on the related list to allow me to edit multiple records associated to an account, it brings back ALL Product Sales records when I am trying to filter by the current Account.  How can I bring the current Account ID into my VFP to filter my list?

 

Class

public class UpdateProductSalesExt{
    public List<Product_Sales__c> sales = new List<Product_Sales__c>([select id from product_sales__c where account__r.id = :ApexPages.currentPage().getParameters().get('id')]);
    public UpdateProductSalesExt(ApexPages.StandardSetController controller) {
        controller.setPageSize(100);
    }
}

 VFP

<apex:page standardController="Product_Sales__c" recordSetVar="sales" tabStyle="Product_Sales__c" extensions="UpdateProductSalesExt">
    <apex:form >
        <apex:pageBlock title="Edit Product Sales" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!sales}" var="ps">
                <apex:column value="{!ps.Account__c}"/>
                <apex:column value="{!ps.Product__r.Product_Category__c}"/>
                <apex:column value="{!ps.Product__c}"/>
                <apex:column headerValue="Total Wallet">
                    <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
                </apex:column>
                <apex:column headerValue="Estimated Percentage of Total Wallet">
                    <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
                </apex:column>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Hi All,

I am trying to update a Lookup Field on an Account with a Trigger.  Essentially I have a Custom Object (Box_Assumptions_c) related to an Account (Account1) and I want to update an a Custom Field (X9Box_Assumptions__c) on a different Account (Account2) with a Box Assumption that is related to Account1 by using the Owner's (Portal User) Contact Account (Account1).

 

trigger updatecustomer9box on Account (before insert, before update) {
    
    //Get Account ID of the current record.
    set<id> acctid = new set<id>();
    for (account a : trigger.new)
    acctid.add(a.owner.contact.account.id);
    
    map<id, box_assumptions__c> boxmap = new map<id, box_assumptions__c>([select id 
                                                                     from box_assumptions__c
                                                                     where account__c in : acctid]);
    for (account a : trigger.new){
        box_assumptions__c thisbox = boxmap.get(a.x9box_assumptions__c);
        a.x9box_assumptions__c = thisbox.id;
    }
}

 I am getting a Null Pointer Exception so any advice would be helpful!

 

-Thanks in advance!

 

I am trying to set an Account Lookup field on all Accounts owned by Contacts who are Portal Users under an Account.

 

Essentially, Portal User A is under Account A.  When I update Account A, I want to update all of Portal User A's Accounts with the Account A Account Id.  Can't seem to get this to work.  Any advice?

 

trigger UpdateClientAccount on Account (after update) {
    
    Set<Id> acctId = new Set<Id>();
    for (Account acct : Trigger.new)
    acctId.add(acct.id);
    
    Map<Id, Contact> contacts = new Map<Id, Contact>(
    [select id from contact
    where id in :acctId]);

    Map<Id, User> users = new Map<Id, User>(
    [select id from user
    where id in :Trigger.oldMap.keySet()]);
        
    for (Account accounts : [select Owner_s_Client_Account__c from Account
    where OwnerId in :Trigger.oldMap.keySet()])
    accounts.Owner_s_Client_Account__c = acctId;

}

 

I have created a custom object (Product_Sales__c) that is related to Accounts and when I try to create a custom list button on the related list to allow me to edit multiple records associated to an account, it brings back ALL Product Sales records when I am trying to filter by the current Account.  How can I bring the current Account ID into my VFP to filter my list?

 

Class

public class UpdateProductSalesExt{
    public List<Product_Sales__c> sales = new List<Product_Sales__c>([select id from product_sales__c where account__r.id = :ApexPages.currentPage().getParameters().get('id')]);
    public UpdateProductSalesExt(ApexPages.StandardSetController controller) {
        controller.setPageSize(100);
    }
}

 VFP

<apex:page standardController="Product_Sales__c" recordSetVar="sales" tabStyle="Product_Sales__c" extensions="UpdateProductSalesExt">
    <apex:form >
        <apex:pageBlock title="Edit Product Sales" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!sales}" var="ps">
                <apex:column value="{!ps.Account__c}"/>
                <apex:column value="{!ps.Product__r.Product_Category__c}"/>
                <apex:column value="{!ps.Product__c}"/>
                <apex:column headerValue="Total Wallet">
                    <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
                </apex:column>
                <apex:column headerValue="Estimated Percentage of Total Wallet">
                    <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
                </apex:column>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Hi All,

I am trying to update a Lookup Field on an Account with a Trigger.  Essentially I have a Custom Object (Box_Assumptions_c) related to an Account (Account1) and I want to update an a Custom Field (X9Box_Assumptions__c) on a different Account (Account2) with a Box Assumption that is related to Account1 by using the Owner's (Portal User) Contact Account (Account1).

 

trigger updatecustomer9box on Account (before insert, before update) {
    
    //Get Account ID of the current record.
    set<id> acctid = new set<id>();
    for (account a : trigger.new)
    acctid.add(a.owner.contact.account.id);
    
    map<id, box_assumptions__c> boxmap = new map<id, box_assumptions__c>([select id 
                                                                     from box_assumptions__c
                                                                     where account__c in : acctid]);
    for (account a : trigger.new){
        box_assumptions__c thisbox = boxmap.get(a.x9box_assumptions__c);
        a.x9box_assumptions__c = thisbox.id;
    }
}

 I am getting a Null Pointer Exception so any advice would be helpful!

 

-Thanks in advance!

 

I am trying to set an Account Lookup field on all Accounts owned by Contacts who are Portal Users under an Account.

 

Essentially, Portal User A is under Account A.  When I update Account A, I want to update all of Portal User A's Accounts with the Account A Account Id.  Can't seem to get this to work.  Any advice?

 

trigger UpdateClientAccount on Account (after update) {
    
    Set<Id> acctId = new Set<Id>();
    for (Account acct : Trigger.new)
    acctId.add(acct.id);
    
    Map<Id, Contact> contacts = new Map<Id, Contact>(
    [select id from contact
    where id in :acctId]);

    Map<Id, User> users = new Map<Id, User>(
    [select id from user
    where id in :Trigger.oldMap.keySet()]);
        
    for (Account accounts : [select Owner_s_Client_Account__c from Account
    where OwnerId in :Trigger.oldMap.keySet()])
    accounts.Owner_s_Client_Account__c = acctId;

}