• Daniel Zeidler (DZ)
  • NEWBIE
  • 100 Points
  • Member since 2013
  • Developer
  • Magnet 360


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

Is there a way to get a list of Account records (parent) with no child records associated (Opportunity)  via SOQL?

I am trying to avoid doinf this in Apex, like getting the AccountId values from Opportunity and then query accounts where id not in this list.

 

Is it possible to get this list through SQOL?


Here is my query (I need only the accounts that have no associated Opportunity records):

 

SELECT a.Id, a.Name, (Select id from Opportunities) from Account a order by a.Name

 

Thanks,

Rodrigo

I've looked but have failed to find a remedy thus far. Any input is welcome. 

 

I have a page that creates multiple records at once, with buttons that can add or remove rows(new records) to a pageblocktable. This works. All the records save perfectly. 

 

In addition to these rows there are other inputfields that contain information that should be applied to every single new record. The data from these inputfields does not save. All the fields are found under the same object "End_of_Month_Report__c". Below is the VF page. HTML has been added to format the layout.  

 

<apex:page standardController="End_of_Month_Report__c" extensions="ReportEntry" Title="New End of the Month Report">
<h1><b><font size="5" face="Times New Roman">New End of the Month Report</font></b></h1>

    <apex:form title="New End of the Month Report">
     
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="table" />
                <apex:commandButton value="Cancel" action="{!cancel}" rerender="table" />
            </apex:pageBlockButtons>
            <apex:pageblocksection title="Data for All Cities in the Region" id="PBS" collapsible="false">
           
            <apex:pageBlockTable value="{!Report}" var="a" id="table">
                <apex:column headerValue="Station [Domicile First] :">
                    <apex:inputField value="{!a.Station_1__c}"/>
                </apex:column> 
                               
                <apex:column headerValue="Fully Staffed?">
                    <apex:inputField value="{!a.Staffing_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Staffing Comments :">
                    <apex:inputField value="{!a.Staffing_Comments_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Date of Station Visit :">
                    <apex:inputField value="{!a.Visit_Date_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Comments Regarding Visit :">
                    <apex:inputField value="{!a.Visit_Comments_Station_1__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
            </apex:pageblockSection>
            
<table width="54%">
    <tr><td>
    <apex:pageblocksection title="Domicile Specifics" collapsible="false" ID="DomicileSpecifics">
        <apex:panelGrid columns="2" width="50%" id="DomicileSpecificsGrid">
          <apex:outputText ><b>OT Goal</b></apex:outputText>
          <apex:outputText ><b>OT Actual</b></apex:outputText>
            <apex:inputtext value="{!theText}" id="OTGoalInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputtext>
            <apex:inputField value="{!End_of_Month_Report__c.OT_Actual_Station_1__c}" id="OTActualInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputfield>
          <apex:outputText ><b>Hours Planned</b></apex:outputText>
          <apex:outputText ><b>Hours Actually Worked</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Planned_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Worked_Station_1__c}"/>
            <apex:outputText ><b>OPs Taken Total </b></apex:outputText>
            <apex:outputText ><b>OP-04 Delays Total </b></apex:outputText>  
            <apex:inputField value="{!End_of_Month_Report__c.OPs_Taken_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.OP_04_Delays_Station_1__c}"/>
        </apex:panelGrid>
    </apex:pageblockSection>
    </td>
        
        <td>
        <apex:pageblocksection title="Customer Interactions" collapsible="false">
        <apex:panelGrid columns="2" width="50%">
            <apex:outputText ><b>Sales Call Comments</b></apex:outputText>
            <apex:outputText ><b>Customer Issues</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Sales_Call_Customer_Comments_1__c}"/>            
            <apex:inputField value="{!End_of_Month_Report__c.Customer_Issue_1__c}"/>
        </apex:panelGrid>
        </apex:pageblockSection>
        </td></tr>
        </table>    
      
    <apex:pageblockButtons location="Top" Title="Add/Remove a City?">
        <div style="text-align:left;font-weight:bold;">
            <apex:commandLink value="Add Another City" action="{!addRow}" rerender="table" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove City" action="{!removeRow}" rerender="table" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 Controller.

Public class ReportEntry {

    public List<End_Of_Month_Report__c> Report {get; set;}

    public ReportEntry(ApexPages.StandardController myController) {
        Report = new List<End_Of_Month_Report__c>();
        Report.add(New End_Of_Month_Report__c());
        }
        

    public void addrow() {
        Report.add(new End_Of_Month_Report__c());}
            
    public void removerow(){
        Integer i = Report.size();
        Report.remove(i-1);}
    
    public PageReference save() {
        system.debug('xxxxxxxxxxxxxxxxx'+ Report);
        insert Report;
        PageReference gorecord = new PageReference('/a1N/o');
        gorecord.setRedirect(true);
        return gorecord; }}

 The fields that do not save are between the <table> tags. 

 

Anyone know where I have gone awry?

 

Thanks!

  • June 27, 2013
  • Like
  • 0

Trying to wrap my head around SOQL syntax and Joins.

I have been a SQL Server DBA/Developer for over 10 years and this Apex/SOQL stuff is confusion :-)

 

I need to Select all Account records where the associated Lead's Owner is like 'Queue')

 

First I tried this

SELECT Id FROM Account WHERE Id IN (SELECT Related_Owner__r.Id From Lead WHERE Owner.Name like '%Queue%')

 

But recieve the error "cannot have more than one level of relationships"

 

So I tried this

SELECT ID,(SELECT Owner.Name FROM Leads__r WHERE Owner.Name like '%Queue%') FROM Account 

 

This Runs but since it is a left join it returns all Accounts and any leads that match

 

I would like to do something like this

SELECT ID,(SELECT Owner.Name FROM Leads__r WHERE Owner.Name like '%Queue%') FROM Account  Where Leads__r.Id != null

 

But that does not work

 

How can I refrence a field form the right part of my join in the where clause

 

I have requirement to create a list view button on Accountcert object. That button just need to call the webservice  method. this is my requirement. 
that method need to pass parameters. how could i achieve this? this need to support in lightning as well
I'm a newbie to Salesforce and Apex.  I have a requirement to create a dynamic banner for Account pages based on criteria from another object where the options are entered by the user.  So I'm adding a new visualforce page (which will be the banner) to the Account object.  I'm can't seem to retrieve the current account ID from the account page.

Visualforce:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
    text-align:center;
    font-weight:bold;
    font-size:150%;
    padding:17px;
    width:80%;
    height:80x;
}
</style>

    <apex:repeat value="{!lstPB}" var="pb" >
    <apex:repeat value="{!acct}" var="a" >
        <div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
            <apex:outputPanel >
                <apex:outputText value="{!a.Industry}"></apex:outputText><br/>
                <apex:outputText value="{!a.Phone}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
                <apex:outputText value="{!a.Id}"></apex:outputText>
            </apex:outputPanel>
         </div>
    </apex:repeat>
    </apex:repeat>
</apex:page>

Apex:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
    text-align:center;
    font-weight:bold;
    font-size:150%;
    padding:17px;
    width:80%;
    height:80x;
}
</style>

    <apex:repeat value="{!lstPB}" var="pb" >
    <apex:repeat value="{!acct}" var="a" >
        <div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
            <apex:outputPanel >
                <apex:outputText value="{!a.Industry}"></apex:outputText><br/>
                <apex:outputText value="{!a.Phone}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
                <apex:outputText value="{!a.Id}"></apex:outputText>
            </apex:outputPanel>
         </div>
    </apex:repeat>
    </apex:repeat>
</apex:page>
I have created a custom object called Project and which holds two look up fields Project_Manager__c and Project_Coordinator__c. I am trying to have those fields be updated by the look up fields on the Account object also named Project_Manager__c and Project_Coordinator__c when a project is created. Any help is greatly appreciated. I was told apex trigger was the way to go. 

Thanks. 
Hello,
I am quite new to Salesforce and Apex (however I am very familiar with Java), so any help explained in simple terms would be much appreciated.

I am trying to write an Apex Trigger that will simply get the fields (shown below) of a Case on its creation. The fields I am trying to access are:

caseRecord, caseOwner, contactName, accountName, products, priority, status, caseOrigin, customerType, date/timeOpened, ticketDesc, subject, originator, reporter, primaryVendor, secondaryVendor, vendorStatus, createdBy, lastModifiedBy

I believe some of the fields may be custom fields, so I am also wondering how I would get those fields.

I would also like to get any attachments, related cases, and comments on the case, so if someone could tell me how I can access those, that would be very helpful.

 Thanks in advance to anyone who puts in the time to help answer my question!

Fayyad

 
Hello everyone,

I have a trigger i am in the process of writing that works fine, i just want to add the stipulation that if the Fuzion_Status__c is changed from "Initial Phone Call' to "Closed" I don't want the trigger to fire and create the Case
 
trigger caseCheck on Account (After update) {
        //Get all account and cases.
  

  List<Account> allAccounts = new List<Account>([Select id,Fuzion_Status__c,(select id from cases where status in('New','On Service')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    Account oldAccount = trigger.oldMap.get(myAccount.id);
    if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call'){
        if(myAccount.cases.isEmpty()){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'SHIP';
            c.Division__c = 'Case Management';
            c.Status = 'New';
            c.RecordTypeId = '01236000000OJLq';
            newCases.add(c); 
        }
     }
        
    }
    if(!NewCases.isEmpty()){
        insert newCases;
    }
 
}

Right now i have this Map that checks to see if the Fuzion Status has been changed to any of the other pick list values, i want it to still fire on any of the picklist values EXCEPT when it is changed to "Closed"
 
if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call')

 
Help Help Help!!!   I somehow deleted my visual flow and I dont see it in the recyle bin.   Any way to recover it?!?!?!!?!?!
I have a below VF code for javascript button this is working in classic but in lightning it's not working , Please suggest me how to enable this code for Lightning.
 
<input type="button" value="New Program" class="btn" onClick="createNewProgram();" title="New Marketing Program record"/>

function createNewProgram() {
  window.open('{!URLFOR($Action.Marketing_Programs__c.New)}', '_new');
}

 
I am new apex programming and am struggling a little bit. I have pieced together some code in an attempt to build a rollup from the Assets to Contracts.

The trigger is supposed to be able to get sum all of the assets' summary_asset_cost__c fields that are related to the contract and post it to the base_product_rev__c field on the contract. I am getting an error when trying to call the relationship in the second query. Also please notfiy if this is the best way to accomplish this goal, as stated before I am not real skilled in apex programming.



trigger AssetCostRollup on Asset (after delete, after insert, after update) {

    Set<id> contractIds = new Set<id>();
    List<Contract> contractsToUpdate = new List<Contract>();

    for (Asset item : Trigger.new)
        contractIds.add(item.Asset);

    if (Trigger.isUpdate || Trigger.isDelete) {
        for (Asset item : Trigger.old)
            contractIds.add(item.Contract);
    }

    // get a map of the contracts and the costs of the assets on the contract
    Map<id,Contract> contractMap = new Map<id,Contract>([select id, summary_asset_cost__c from Asset where id IN :contractIds]);

    // query the contracts and the related assets and sum the cost of the assets to the contracts base_product_rev__c field
    for (Contract contract : [select Id, Name, summary_asset_cost__c,(select id from contract_lookup__r) from Asset where Id IN :contractIds]) {
        contractMap.get(contract.Id).asset_summary_cost__c = contract.base_product_rev__c.sum();
        
        contractsToUpdate.add(contractMap.get(contract.Id));
    }

    update contractsToUpdate;

}
}
 

Hi,

 

I have a trigger on a custom object called service__c which is a child of account. Trigger prevents users to have more than one open service for an account at the same time (pick list status__c field). My problem here is It does not allow me to update picklist value for the open account eventhough this is the only open account. My code is below:

public with sharing class ServiceTriggerHandler {
	private boolean m_isExecuting = false;
	private integer BatchSize = 0;
	
	/*public ServiceTriggerHandler(boolean isExecuting, integer size){
		m_isExecuting = isExecuting;
		BatchSize = size;
	}*/
	
	public void servicestatusvalidationmethod(List<Service__c> services){
        Set<id>serviceids = new Set<id>{};
        
        for(Service__c service:services){
            //if(service.Status__c != 'Closed'){
				serviceids.add(service.Account__c);
           // }
        }
        List<Service__c> allactiveservices = [select id, Status__c,Account__c from Service__c where Account__c IN: serviceids and Status__c != 'Closed'];
        System.debug(allactiveservices);
        
        for(Service__c newservice:services){
            for(Service__c servicesvalidation:allactiveservices){
                if(newservice.status__c != 'Closed'){
                	newservice.addError('There is already one Active Service For this Account');
            	}
            }
        }
    }
}

 

 

Any help would be highly appreciated.

 

Thanks,

Hi,

 

Below is my vf page. I have used action function control and java script to call controller method. When I have created this page, it was working perfactly. But today it is not working, I am not able to find any reason for that. If I use action in commandbutton directly then it works fine (that means my controller works fine). But as per my requirement I have to call that action using action function as this is a popup page.

 

<apex:page id="pg" controller="GeneralSettingsController" sidebar="false" showHeader="false">
    <apex:pageMessages id="msg"/>
    <apex:form id="frm">
        <apex:PageBlock id="pb">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save Settings" onclick="SaveSettings();"/>
                <apex:commandButton value="Cancel" onclick="window.close();"/>
            </apex:pageBlockButtons>
            Save Status: <B>{!saveStatus}</B><BR/><BR/>
            Remove chat history prior to &nbsp;&nbsp;<apex:inputField style="width:30px" value="{!objSetting.Time_Digit__c}"/>&nbsp;&nbsp;
            <apex:selectList style="width:75px" size="1" multiselect="false" value="{!objSetting.Time_Unit__c}">
                <apex:selectOption itemValue="Minutes" itemLabel="Minutes"/>
                <apex:selectOption itemValue="Hours" itemLabel="Hours"/>
                <apex:selectOption itemValue="Days" itemLabel="Days"/>
            </apex:selectList>
            
        </apex:PageBlock>
        <apex:actionFunction oncomplete="window.close();" id="afSaveSettingValues" name="SaveSettingValues" action="{!SaveSettings}"/>
    </apex:form>
    
    <script>
        function SaveSettings(){
            pg:frm:SaveSettingValues();
        }
    </script>
</apex:page>

 Please give me some suggestion to find out cause.

Is there a way to get a list of Account records (parent) with no child records associated (Opportunity)  via SOQL?

I am trying to avoid doinf this in Apex, like getting the AccountId values from Opportunity and then query accounts where id not in this list.

 

Is it possible to get this list through SQOL?


Here is my query (I need only the accounts that have no associated Opportunity records):

 

SELECT a.Id, a.Name, (Select id from Opportunities) from Account a order by a.Name

 

Thanks,

Rodrigo

I've looked but have failed to find a remedy thus far. Any input is welcome. 

 

I have a page that creates multiple records at once, with buttons that can add or remove rows(new records) to a pageblocktable. This works. All the records save perfectly. 

 

In addition to these rows there are other inputfields that contain information that should be applied to every single new record. The data from these inputfields does not save. All the fields are found under the same object "End_of_Month_Report__c". Below is the VF page. HTML has been added to format the layout.  

 

<apex:page standardController="End_of_Month_Report__c" extensions="ReportEntry" Title="New End of the Month Report">
<h1><b><font size="5" face="Times New Roman">New End of the Month Report</font></b></h1>

    <apex:form title="New End of the Month Report">
     
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="table" />
                <apex:commandButton value="Cancel" action="{!cancel}" rerender="table" />
            </apex:pageBlockButtons>
            <apex:pageblocksection title="Data for All Cities in the Region" id="PBS" collapsible="false">
           
            <apex:pageBlockTable value="{!Report}" var="a" id="table">
                <apex:column headerValue="Station [Domicile First] :">
                    <apex:inputField value="{!a.Station_1__c}"/>
                </apex:column> 
                               
                <apex:column headerValue="Fully Staffed?">
                    <apex:inputField value="{!a.Staffing_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Staffing Comments :">
                    <apex:inputField value="{!a.Staffing_Comments_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Date of Station Visit :">
                    <apex:inputField value="{!a.Visit_Date_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Comments Regarding Visit :">
                    <apex:inputField value="{!a.Visit_Comments_Station_1__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
            </apex:pageblockSection>
            
<table width="54%">
    <tr><td>
    <apex:pageblocksection title="Domicile Specifics" collapsible="false" ID="DomicileSpecifics">
        <apex:panelGrid columns="2" width="50%" id="DomicileSpecificsGrid">
          <apex:outputText ><b>OT Goal</b></apex:outputText>
          <apex:outputText ><b>OT Actual</b></apex:outputText>
            <apex:inputtext value="{!theText}" id="OTGoalInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputtext>
            <apex:inputField value="{!End_of_Month_Report__c.OT_Actual_Station_1__c}" id="OTActualInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputfield>
          <apex:outputText ><b>Hours Planned</b></apex:outputText>
          <apex:outputText ><b>Hours Actually Worked</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Planned_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Worked_Station_1__c}"/>
            <apex:outputText ><b>OPs Taken Total </b></apex:outputText>
            <apex:outputText ><b>OP-04 Delays Total </b></apex:outputText>  
            <apex:inputField value="{!End_of_Month_Report__c.OPs_Taken_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.OP_04_Delays_Station_1__c}"/>
        </apex:panelGrid>
    </apex:pageblockSection>
    </td>
        
        <td>
        <apex:pageblocksection title="Customer Interactions" collapsible="false">
        <apex:panelGrid columns="2" width="50%">
            <apex:outputText ><b>Sales Call Comments</b></apex:outputText>
            <apex:outputText ><b>Customer Issues</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Sales_Call_Customer_Comments_1__c}"/>            
            <apex:inputField value="{!End_of_Month_Report__c.Customer_Issue_1__c}"/>
        </apex:panelGrid>
        </apex:pageblockSection>
        </td></tr>
        </table>    
      
    <apex:pageblockButtons location="Top" Title="Add/Remove a City?">
        <div style="text-align:left;font-weight:bold;">
            <apex:commandLink value="Add Another City" action="{!addRow}" rerender="table" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove City" action="{!removeRow}" rerender="table" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 Controller.

Public class ReportEntry {

    public List<End_Of_Month_Report__c> Report {get; set;}

    public ReportEntry(ApexPages.StandardController myController) {
        Report = new List<End_Of_Month_Report__c>();
        Report.add(New End_Of_Month_Report__c());
        }
        

    public void addrow() {
        Report.add(new End_Of_Month_Report__c());}
            
    public void removerow(){
        Integer i = Report.size();
        Report.remove(i-1);}
    
    public PageReference save() {
        system.debug('xxxxxxxxxxxxxxxxx'+ Report);
        insert Report;
        PageReference gorecord = new PageReference('/a1N/o');
        gorecord.setRedirect(true);
        return gorecord; }}

 The fields that do not save are between the <table> tags. 

 

Anyone know where I have gone awry?

 

Thanks!

  • June 27, 2013
  • Like
  • 0

Hello, I need to know how to reference a Contact field within the trigger of a child object.  I need to reference the Contact field in an IF THEN statement.

 

Thanks!

 

Kevin

 

Here is more detail:

Trigger needs to reference Customer field and custom object.

I'm doing a record count on an object related to Contacts: npe5__Affiliation__c
This works great.  However, I need to use a Customer field in my IF statement.
I want to change it from:

if(recordcount >= 1)
to various versions of:
if(recordcount >= 1 && Customer.Guest_Speaker__c = TRUE) 


Integer recordcount = [select count() from npe5__Affiliation__c where npe5__contact__c = :record.npe5__contact__c AND Type__c = 'Speaker'];

if(recordcount >= 1)
{
	// Update checkbox field on the Contact record to TRUE                
	contacts.put(record.npe5__contact__c, new contact(id=record.npe5__contact__c, Guest_Speaker__c = TRUE)); 
Else {
       // Update checkbox field on the Contact record to TRUE                
	contacts.put(record.npe5__contact__c, new contact(id=record.npe5__contact__c, Guest_Speaker__c = FALSE));                
	}
	update contacts.values();   
}

 

 

 

 

 

On opportunity, I have a lookup to case.  Whenever a case is moved to status 'Cancelled/declined', I want the opportunity stage to go to "Closed-Lost".  I have written a trigger below, but it doesn't seem to be working.  Any help would be greatly appreciated.

 

trigger ClosedLostOpp2 on Case (after update) {
    //create list of case IDs
    List<ID> cid = New List<ID>();
    //find cases to add to list
    for(Case c: Trigger.new){
        if(c.Status == 'Cancelled/declined'){
            cid.add(c.Id);
        }
       
             
             
             
     List<Opportunity> OppUpdateList = [SELECT Id, StageName from Opportunity WHERE ID in:cid];
        List<Opportunity> opp = new List<Opportunity>();
        for (Opportunity oppsupd : oppUpdateList)
        {
            oppsupd.StageName = 'Closed-Lost';
            opp.add(oppsupd);
        }
        update opp;
        
            

}
}

 

Hi,

 

I am trying to create an Apex trigger between 2 cross object fields.

 

I have a custom object Sale_c , and there is a (number) formula field Outstanding_Data_c calculating the outstanding number of Data outstanding on the sale. The value of this field is constantly changin automatically when Data is delivered.

 

I have another custom object Sale_allocation_c and there is a number field SA_Outstanding_Data_c . I would like this field to be updated with the value of Outstanding_Data_c automatically. Not sure if it makes a difference but Sale_allocation_c is the child and Sale_c is the parent in the relationship.

 

Could anyone offer me some expertise and help me with the code? I would really appreciate it.

 

Many Thanks

  • June 10, 2013
  • Like
  • 0

Hi All,

 

Is there an easy way to update a field on Master record,as a result of approval process on detail object(both custom)