• sean.gorman@ipc.com
  • NEWBIE
  • 30 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 15
    Replies

Hi,

I have a new custom object stores Opportunity related data which can be used to create a new opportunity.

 

I cannot think of a way to store the new OPPID in the relavent record.

 

trigger Process_IB2U on IB2U__c (Before Update) {

set<id> IBIds = new set<id>();
map<id,id> mapIBtoOpp = new map<id,id>();
list<IB2U__c> newIB2U = new list<IB2U__c>();

set<IB2U__c> IBs_toUpdate = new set<IB2U__c>();
list<Opportunity> Opp_forInsert = new list<Opportunity>();
Pricebook2[] priceBook = [Select p.Name, p.Id From Pricebook2 p where p.Name = 'Trading Price Book'];

	for(IB2U__c IB: trigger.new)
	{ 
		if(IB.Convert_to_Opportunity__c == TRUE)
		{
			IBs_toUpdate.add(IB);
			Opportunity oppty = new Opportunity (StageName = 'Price / Quote', Opp_Probability__c = '60', Name = 'IB2U Converted Opp',
									Estimated_Revenue_Amount__c = IB.Estimated_Revenue_Amount__c, CloseDate = IB.Estimated_Contract_Date__c,
									Amount = 200, AccountId = IB.Account__c, CurrencyIsoCode = IB.CurrencyIsoCode, Unigy__c = TRUE, 
									Site_Name__c = IB.Account_Site__c, Distributor__c = IB.Distributor__c, Pricebook2Id = priceBook[0].Id, Incumbent__c = IB.Incumbant__c );
			Opp_forInsert.add(oppty);

		}
	}
	insert Opp_forInsert;


	for(Opportunity Oppt: Opp_forInsert)
	{
		// this does not work as IB is out of context
		IB.Opportunity__c = Oppt.id;
		
	}
	// Again - will not work
	update IB;

}

 

 

I have a couple of SETs and MAPs that are not currently used... I was playing with them to get the ID of the IB and OPP together - but I cannot without requerying the Opportunity table with a related list of IB.IDs and saving the related IB on the Opportunity.

 

 

Hi,

 

I am writing a trigger to create a new object related to an opportunity when a certain thing happens.

 

Right now that 'certain thing' is a button click that sets a checkbox. That button checks to see if a review has already been created by checking to see if the checkbox is set and if not sets it. When an update happens where the RevRequired__c checkbox = 1 then I am going to insert a new related review.

 

Now then. What would the best practice be?

Use the trigger old/new map to see if the checkbox was checked before and is now.

Use 2 fields, (RevRequired__c and RevDone__c) one to check if it has been done and one to kick off the process.

I know that this has been dealt with many times but I cannot see what more I can do.

 

Account is top level:

    Opportunities are related to Accounts (as expected)

    CEPs are related to Accounts

        Tasks are related to CEPs (for this example)

 

CEPs are a envelope to hold tasks related to the Customer Engagement Plan. A trigger recreates tasks on 2 parameters stored in CEP (different for each account - a way to create recurring tasks without seeing them all created at once)

 

The issue is that we integrate into the system once per hour to load quotes related to opportunities and this updates the opportunity thus causing too many queries.

 

The trigger below finds any CEP tasks owned by the owner of the updated opportunity and completes the task if it is past due or up to 14 days in the future.

 

Anyone got a pointer on how this code could be better?

 

trigger UpdateCEPfromOpp on Opportunity (after insert, after update) {

       /*
        #1 Find the account ID of this opportunity  
        #2 Find all of THIS USERS CEPs related to the account found in #1
        #3 Check to see if there is an End date in the past
        #4 find all of the CURRENT tasks related to the CEPs in #3
        #5 check to see if the tasks are either past due or in next 2 weeks 
        #6 update task, if found, with comment.
        */

	if (!CEPTasksFromOppHelper.hasAlreadyCreatedFollowUpTasks()) 
	{
		for (Opportunity o: trigger.new)
		{
		    date dtWhen;
	    	date dtToday;
	
		    dtToday = system.today();
	    	list<Opportunity> Opps = 
	    	[
		        select id, accountid, ownerid
		        from Opportunity
		        where ID IN :Trigger.newMap.keyset()
		    ];
		    system.debug(Opps);
		    Set<ID> idAccount = New Set<ID>();
		    Set<ID> idOwner = New Set<ID>();

			for (Opportunity Opp : Opps)
	        {
	            idAccount.add(Opp.Accountid);
	            idOwner.add(Opp.OwnerID);
	        }
	        Set<ID> idCEP = New Set<ID>();
	
			if(!Opps.isEmpty())
			{
		        for(Customer_Engagement_Plan__c CEPs : [Select ID, End_Date__c
		                                                from Customer_Engagement_Plan__c CP 
		                                                where (CP.Account__c IN :idAccount and CP.OwnerID in :idOwner)])
		        {
		            if(CEPs.End_Date__c != null)
		            {
		                dtWhen = CEPs.End_Date__c;
		                system.debug(dtWhen);
		                if(dtToday.daysbetween(dtWhen) < 0) 
		                {
		                    idCEP.add(CEPs.ID);
		                }
		            }
		            else
		            {
		                idCEP.add(CEPs.ID);
		            }
		        }
			}
		
		    system.debug(idCEP);
		    list<Task> tasksToUpdate = New list<Task>{};
			if(!idCEP.isEmpty())
			{
				for(Task Tasks : [Select id, accountid, CEP_Activity__c, whatID, Subject, Status, Ownerid, Description, ActivityDate
			                      from Task 
			                      where (WhatID IN :idCEP) and Status <> 'Completed'])
			    {
			    	system.debug(tasks.ActivityDate);
			        system.debug(system.today().daysbetween(tasks.ActivityDate));
			        //if(tasks.ActivityDate.daysbetween(system.today()) < 14)
			        if(system.today().daysbetween(tasks.ActivityDate) < 14)
			        {
			        	date dtDisplay = date.newinstance(o.closedate.year(), o.closedate.month(), o.closedate.day());
			            Tasks.Status = 'Completed';
			            Tasks.Description = 'Opportunity ID ' + o.SFDC_Opportunity_Unique_ID__c + ' was updated. Close date is ' + dtDisplay + ' and Estimated revenue is '+ o.Estimated_Revenue_Amount__c ;
			            tasksToUpdate.add(tasks);
			        }
		     	}
			    if(tasksToUpdate.size() > 0)
			    {
			        update tasksToUpdate;
			    }
			}
			CEPTasksFromOppHelper.setAlreadyCreatedFollowUpTasks();
		}
	}
}

 

I have a custom object called Demo Booking (DB).

I have another custom object as a related list called Demo Booking Object (DBO).

 

DBO is related to DB and to another table called Demo Object (DO). Demo objects are items that we use in our demo. They have a type and a minutes.

 

For clarity:

DBs are the BOOKINGS. DO are the OBJECTS and DBOs are the link between the two (like Opportunities, Products and Opportuntiy Products)

 

The user has to create a new Booking (DB). Once they have done that they have to select the Objects (DO) using the DBO related list. This uses the standard SFDC "Search" then "Save and New" method. The issue is that most Sales people do not really know these objects and searching for them is clunky.

 

I created a new visulaforce page on top of the DO object which displays the Objects along with their name and a checkbox.

 

The idea being that they open the new page from their new Booking and can just check the box next to the items to associate Booking#1 with Objects #1,2,3,5,6,9.

 

Finally: DBO rolls up the selected DOs' minutes to give us an approximate time for the demo.

 

If I go to the apex page this display correctly.

 

 

public class DemoObjectsShowAll{
     
        //Collection of the class/wrapper objects cObject
        public List<cObjects> objectList {get; set;}
     
        //This method uses a simple SOQL query to return a List of Objects
        public List<cObjects> getAllDemoObjects() {
            if(objectList == null) {
                objectList = new List<cObjects>();
                for(SE_Demo_Objects__c d :    [SELECT Name, Minutes_for_Demo__c, Product_Type__c FROM SE_Demo_Objects__c LIMIT 50]) {
                    // As each object is processed we create a new demo object and add it to the ObjectList
                    objectList.add(new cObjects(d));
                }
            }
            return objectList;
        }
     
     
        public PageReference processSelected() {
     
                    //We create a new list of Objects that we be populated only with Objects if they are selected
            List<SE_Demo_Objects__c> selectedObjects = new List<SE_Demo_Objects__c>();
     
            //We will cycle through our list of cObjects and will check to see if the selected property is set to true, if it is we add the Objects to the selectedObjects list
            for(cObjects cObj : getAllDemoObjects()) {
                if(cObj.selected == true) {
                    selectedObjects.add(cObj.Obj);
                }
            }
     
            // Now we have our list of selected objects
            System.debug('These are the selected Objects...');
            for(SE_Demo_Objects__c Obj : selectedObjects) {
                system.debug(Obj);
            }
            return null;
        }
     
     
        // This is our wrapper/container class. 
        public class cObjects {
            public SE_Demo_Objects__c Obj{get; set;}
            public Boolean selected {get; set;}
     
            //This is the contructor method. 
            public cObjects(SE_Demo_Objects__c d) {
                Obj = d;
                selected = false;
            }
        }
    }

 

<apex:page Controller="DemoObjectsShowAll" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add items to your Demo" action="{!processSelected}" rerender="table"/>
            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!allDemoObjects}" var="demo">

                <!-- This is our selected Boolean property in our wrapper class -->
                <apex:column >
                    <apex:inputCheckbox value="{!demo.selected}"/>
                </apex:column>
                <!-- This is how we access the values within our container/wrapper -->

                <apex:column value="{!demo.obj.name}"/>
                <apex:column value="{!demo.obj.Minutes_for_Demo__c}"/>
                <apex:column value="{!demo.obj.Product_Type__c}"/>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Now - I want to associate this with my related list and, of course, it doesn't associate because it is not a standard controller. How do I fix this?

 

The way I see it I have 2 issues:

#1 is that I need to write the the DBO rows from this page so I will need to associate them with the DB ID. (I have not done this as I wanted to do #2 first)

#2 This page needs to plug into the NEW button on the DBO related list on DB but it is related to DO.

 

 

Hi,

 

I need to set a flag on an Opp if a certain type of product is selected... I have code that works.. but I am pretty sure that it isn't as good as it could be and that it will not work on batch. Can anyone give me pointers please?

 

trigger NewDataPrdct on OpportunityLineItem (after insert, after update) {

	public boolean bData;
    Set<String> PBEIdSet = new Set<String>();
    Set<String> Prod2IdSet = new Set<String>();
    list<Id> OppyIDs = new list<Id>();	
	Map<ID, ID> OppMap = New Map<ID, ID>();
	
//get all DATA products
	list<Product2> DataProds = [ Select prod.id from Product2 prod where prod.Oracle_Product_Family__c like '%data%' and IsActive = TRUE ];

// list through all OLIs to build list of oppIDs
    for (OpportunityLineItem updatedLineItem : System.Trigger.new)   
    {
    	System.debug('Line1');
    	OppMap.put(updatedLineItem.OpportunityId, updatedLineItem.PricebookEntryId);
		OppyIDs.add(updatedLineItem.OpportunityId);

        if (updatedLineItem.PricebookEntryId  != null) 
        {
            PBEIdSet.add(updatedLineItem.PricebookEntryId );
        }
    }

	list<Opportunity> Oppys = [select ID, NS_Data_Opp__c, Business_Type__c from Opportunity where id in :OppyIDs];

    list<PricebookEntry> ParentPricebookEntry = [SELECT Product2Id from PricebookEntry where id in :PBEIdSet];

    for(PricebookEntry pbes: ParentPricebookEntry) 
    {           
        if (pbes.Product2Id != null) 
        {
            Prod2IdSet.add(pbes.Product2Id);
        }
    }

    list<Product2> ParentProd = [SELECT ProductCode from Product2 where id in :Prod2IdSet];

    for(Product2 prods: ParentProd) 
    {
        for(Product2 CheckProds : DataProds)
		{
			if(CheckProds.id == prods.id) 
			{
        	   	bData = true;
        	    break;
       		}
		}
    }
	System.debug('bData = ' + bData);
	if(OppMap.size()>0 && bData)
    {
		System.debug('oppmap size > 0 = ' + OppMap); 
		for(Opportunity O : Oppys)
		{
		System.debug('OOOO ' + O); 
			O.NS_Data_Opp__c = TRUE;
			update O;
		}
	}
}

 

 

Hi,


I'm not a trained developer so please excuse me if this seems a bit obvious.


I have 2 custom ojects that are both related to Opportunity. Quote_Request__c (QER) and Quote__c (Q).


These are obviously related one to another. They both hold a field called Quote_Header_ID__c. When a quote is returned by our integration with our internal quoting system we would like to see to which QER the quote is related.


So: there is an additional field on the quote table called Quote_Estimate_Request__c which is a lookup relationship to the Quote_Request__c object.


Quote Header Ids in will be unique for the QER but there may be many quotes related.


So... What I did thus far:

 

trigger addQERassociation on Quote__c (before insert, before update) {

    Decimal dQERid;
    for (Quote__c q :Trigger.new)
    {
        dQERid= q.quote_header_id__c;
        if(dQERid!= '')
        {
            for (List<Quote_Request__c> qer :[Select ID from Quote_Request__c qr where (qr.Quote_Header_ID__c = 123456)]) //dQERid)])
            {
                if(qer.Size() > 0)
                {
                    q.Quote_Estimate_Request__c = qer[0];
                }
            }
        }
    }
}

 

The current issue is that I am getting a compile error: Error: Compile Error: Illegal assignment from SOBJECT:Quote_Request__c to Id at line 13 column 21

 

The other is that I cannot put the variable: dQERid into the select statement as it errors out with: Error: Compile Error: unexpected token: 'dQERid' at line 9 column 112 (Fixed: I added a colon to make :dQERid)

 

 

Does anyone have any advice? Please?

Hi,

I have a new custom object stores Opportunity related data which can be used to create a new opportunity.

 

I cannot think of a way to store the new OPPID in the relavent record.

 

trigger Process_IB2U on IB2U__c (Before Update) {

set<id> IBIds = new set<id>();
map<id,id> mapIBtoOpp = new map<id,id>();
list<IB2U__c> newIB2U = new list<IB2U__c>();

set<IB2U__c> IBs_toUpdate = new set<IB2U__c>();
list<Opportunity> Opp_forInsert = new list<Opportunity>();
Pricebook2[] priceBook = [Select p.Name, p.Id From Pricebook2 p where p.Name = 'Trading Price Book'];

	for(IB2U__c IB: trigger.new)
	{ 
		if(IB.Convert_to_Opportunity__c == TRUE)
		{
			IBs_toUpdate.add(IB);
			Opportunity oppty = new Opportunity (StageName = 'Price / Quote', Opp_Probability__c = '60', Name = 'IB2U Converted Opp',
									Estimated_Revenue_Amount__c = IB.Estimated_Revenue_Amount__c, CloseDate = IB.Estimated_Contract_Date__c,
									Amount = 200, AccountId = IB.Account__c, CurrencyIsoCode = IB.CurrencyIsoCode, Unigy__c = TRUE, 
									Site_Name__c = IB.Account_Site__c, Distributor__c = IB.Distributor__c, Pricebook2Id = priceBook[0].Id, Incumbent__c = IB.Incumbant__c );
			Opp_forInsert.add(oppty);

		}
	}
	insert Opp_forInsert;


	for(Opportunity Oppt: Opp_forInsert)
	{
		// this does not work as IB is out of context
		IB.Opportunity__c = Oppt.id;
		
	}
	// Again - will not work
	update IB;

}

 

 

I have a couple of SETs and MAPs that are not currently used... I was playing with them to get the ID of the IB and OPP together - but I cannot without requerying the Opportunity table with a related list of IB.IDs and saving the related IB on the Opportunity.

 

 

Hi,

 

I am writing a trigger to create a new object related to an opportunity when a certain thing happens.

 

Right now that 'certain thing' is a button click that sets a checkbox. That button checks to see if a review has already been created by checking to see if the checkbox is set and if not sets it. When an update happens where the RevRequired__c checkbox = 1 then I am going to insert a new related review.

 

Now then. What would the best practice be?

Use the trigger old/new map to see if the checkbox was checked before and is now.

Use 2 fields, (RevRequired__c and RevDone__c) one to check if it has been done and one to kick off the process.

I know that this has been dealt with many times but I cannot see what more I can do.

 

Account is top level:

    Opportunities are related to Accounts (as expected)

    CEPs are related to Accounts

        Tasks are related to CEPs (for this example)

 

CEPs are a envelope to hold tasks related to the Customer Engagement Plan. A trigger recreates tasks on 2 parameters stored in CEP (different for each account - a way to create recurring tasks without seeing them all created at once)

 

The issue is that we integrate into the system once per hour to load quotes related to opportunities and this updates the opportunity thus causing too many queries.

 

The trigger below finds any CEP tasks owned by the owner of the updated opportunity and completes the task if it is past due or up to 14 days in the future.

 

Anyone got a pointer on how this code could be better?

 

trigger UpdateCEPfromOpp on Opportunity (after insert, after update) {

       /*
        #1 Find the account ID of this opportunity  
        #2 Find all of THIS USERS CEPs related to the account found in #1
        #3 Check to see if there is an End date in the past
        #4 find all of the CURRENT tasks related to the CEPs in #3
        #5 check to see if the tasks are either past due or in next 2 weeks 
        #6 update task, if found, with comment.
        */

	if (!CEPTasksFromOppHelper.hasAlreadyCreatedFollowUpTasks()) 
	{
		for (Opportunity o: trigger.new)
		{
		    date dtWhen;
	    	date dtToday;
	
		    dtToday = system.today();
	    	list<Opportunity> Opps = 
	    	[
		        select id, accountid, ownerid
		        from Opportunity
		        where ID IN :Trigger.newMap.keyset()
		    ];
		    system.debug(Opps);
		    Set<ID> idAccount = New Set<ID>();
		    Set<ID> idOwner = New Set<ID>();

			for (Opportunity Opp : Opps)
	        {
	            idAccount.add(Opp.Accountid);
	            idOwner.add(Opp.OwnerID);
	        }
	        Set<ID> idCEP = New Set<ID>();
	
			if(!Opps.isEmpty())
			{
		        for(Customer_Engagement_Plan__c CEPs : [Select ID, End_Date__c
		                                                from Customer_Engagement_Plan__c CP 
		                                                where (CP.Account__c IN :idAccount and CP.OwnerID in :idOwner)])
		        {
		            if(CEPs.End_Date__c != null)
		            {
		                dtWhen = CEPs.End_Date__c;
		                system.debug(dtWhen);
		                if(dtToday.daysbetween(dtWhen) < 0) 
		                {
		                    idCEP.add(CEPs.ID);
		                }
		            }
		            else
		            {
		                idCEP.add(CEPs.ID);
		            }
		        }
			}
		
		    system.debug(idCEP);
		    list<Task> tasksToUpdate = New list<Task>{};
			if(!idCEP.isEmpty())
			{
				for(Task Tasks : [Select id, accountid, CEP_Activity__c, whatID, Subject, Status, Ownerid, Description, ActivityDate
			                      from Task 
			                      where (WhatID IN :idCEP) and Status <> 'Completed'])
			    {
			    	system.debug(tasks.ActivityDate);
			        system.debug(system.today().daysbetween(tasks.ActivityDate));
			        //if(tasks.ActivityDate.daysbetween(system.today()) < 14)
			        if(system.today().daysbetween(tasks.ActivityDate) < 14)
			        {
			        	date dtDisplay = date.newinstance(o.closedate.year(), o.closedate.month(), o.closedate.day());
			            Tasks.Status = 'Completed';
			            Tasks.Description = 'Opportunity ID ' + o.SFDC_Opportunity_Unique_ID__c + ' was updated. Close date is ' + dtDisplay + ' and Estimated revenue is '+ o.Estimated_Revenue_Amount__c ;
			            tasksToUpdate.add(tasks);
			        }
		     	}
			    if(tasksToUpdate.size() > 0)
			    {
			        update tasksToUpdate;
			    }
			}
			CEPTasksFromOppHelper.setAlreadyCreatedFollowUpTasks();
		}
	}
}

 

I have a custom object called Demo Booking (DB).

I have another custom object as a related list called Demo Booking Object (DBO).

 

DBO is related to DB and to another table called Demo Object (DO). Demo objects are items that we use in our demo. They have a type and a minutes.

 

For clarity:

DBs are the BOOKINGS. DO are the OBJECTS and DBOs are the link between the two (like Opportunities, Products and Opportuntiy Products)

 

The user has to create a new Booking (DB). Once they have done that they have to select the Objects (DO) using the DBO related list. This uses the standard SFDC "Search" then "Save and New" method. The issue is that most Sales people do not really know these objects and searching for them is clunky.

 

I created a new visulaforce page on top of the DO object which displays the Objects along with their name and a checkbox.

 

The idea being that they open the new page from their new Booking and can just check the box next to the items to associate Booking#1 with Objects #1,2,3,5,6,9.

 

Finally: DBO rolls up the selected DOs' minutes to give us an approximate time for the demo.

 

If I go to the apex page this display correctly.

 

 

public class DemoObjectsShowAll{
     
        //Collection of the class/wrapper objects cObject
        public List<cObjects> objectList {get; set;}
     
        //This method uses a simple SOQL query to return a List of Objects
        public List<cObjects> getAllDemoObjects() {
            if(objectList == null) {
                objectList = new List<cObjects>();
                for(SE_Demo_Objects__c d :    [SELECT Name, Minutes_for_Demo__c, Product_Type__c FROM SE_Demo_Objects__c LIMIT 50]) {
                    // As each object is processed we create a new demo object and add it to the ObjectList
                    objectList.add(new cObjects(d));
                }
            }
            return objectList;
        }
     
     
        public PageReference processSelected() {
     
                    //We create a new list of Objects that we be populated only with Objects if they are selected
            List<SE_Demo_Objects__c> selectedObjects = new List<SE_Demo_Objects__c>();
     
            //We will cycle through our list of cObjects and will check to see if the selected property is set to true, if it is we add the Objects to the selectedObjects list
            for(cObjects cObj : getAllDemoObjects()) {
                if(cObj.selected == true) {
                    selectedObjects.add(cObj.Obj);
                }
            }
     
            // Now we have our list of selected objects
            System.debug('These are the selected Objects...');
            for(SE_Demo_Objects__c Obj : selectedObjects) {
                system.debug(Obj);
            }
            return null;
        }
     
     
        // This is our wrapper/container class. 
        public class cObjects {
            public SE_Demo_Objects__c Obj{get; set;}
            public Boolean selected {get; set;}
     
            //This is the contructor method. 
            public cObjects(SE_Demo_Objects__c d) {
                Obj = d;
                selected = false;
            }
        }
    }

 

<apex:page Controller="DemoObjectsShowAll" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add items to your Demo" action="{!processSelected}" rerender="table"/>
            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!allDemoObjects}" var="demo">

                <!-- This is our selected Boolean property in our wrapper class -->
                <apex:column >
                    <apex:inputCheckbox value="{!demo.selected}"/>
                </apex:column>
                <!-- This is how we access the values within our container/wrapper -->

                <apex:column value="{!demo.obj.name}"/>
                <apex:column value="{!demo.obj.Minutes_for_Demo__c}"/>
                <apex:column value="{!demo.obj.Product_Type__c}"/>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Now - I want to associate this with my related list and, of course, it doesn't associate because it is not a standard controller. How do I fix this?

 

The way I see it I have 2 issues:

#1 is that I need to write the the DBO rows from this page so I will need to associate them with the DB ID. (I have not done this as I wanted to do #2 first)

#2 This page needs to plug into the NEW button on the DBO related list on DB but it is related to DO.

 

 

Hi,


I'm not a trained developer so please excuse me if this seems a bit obvious.


I have 2 custom ojects that are both related to Opportunity. Quote_Request__c (QER) and Quote__c (Q).


These are obviously related one to another. They both hold a field called Quote_Header_ID__c. When a quote is returned by our integration with our internal quoting system we would like to see to which QER the quote is related.


So: there is an additional field on the quote table called Quote_Estimate_Request__c which is a lookup relationship to the Quote_Request__c object.


Quote Header Ids in will be unique for the QER but there may be many quotes related.


So... What I did thus far:

 

trigger addQERassociation on Quote__c (before insert, before update) {

    Decimal dQERid;
    for (Quote__c q :Trigger.new)
    {
        dQERid= q.quote_header_id__c;
        if(dQERid!= '')
        {
            for (List<Quote_Request__c> qer :[Select ID from Quote_Request__c qr where (qr.Quote_Header_ID__c = 123456)]) //dQERid)])
            {
                if(qer.Size() > 0)
                {
                    q.Quote_Estimate_Request__c = qer[0];
                }
            }
        }
    }
}

 

The current issue is that I am getting a compile error: Error: Compile Error: Illegal assignment from SOBJECT:Quote_Request__c to Id at line 13 column 21

 

The other is that I cannot put the variable: dQERid into the select statement as it errors out with: Error: Compile Error: unexpected token: 'dQERid' at line 9 column 112 (Fixed: I added a colon to make :dQERid)

 

 

Does anyone have any advice? Please?

We have several RecordTypes for our Contacts.  For our "Study Contact" page layout, all the appropriate detail fields are there, and we have a related list that shows Contacts that the current Contact has referred to us.  I want to hide the default New button on this related list and replace it with a "New Referral" button.  Clicking the "New Referral" button should invoke the New action, but set the RecordType to "Study Contact" behind the scenes and bypass the "Select Contact Record Type" page.
 
I have looked everywhere for examples, and managed to put together the following... but it still shows the "Select Contact Record Type" page.   I am putting the RecordType parameter in the parameter array and also including it directly on the URL just in case....  Help?
 
Code:
//First construct the new URL
var newUrl = "{!URLFOR( $Action.Contact.NewContact, null,
[RecordType=Contact.RecordType,
CF00N70000002GKJz_lkid=Contact.Id,
con4_lkid=Account.Id,
retURL=$Request.retURL], true)}&RecordType={!Contact.RecordType}";
//Then redirect the user to it
window.parent.location.replace(newUrl);

This is run in an Execute Javascript button.
I have tried putting the RecordTypeId value in there directly too (rather than use Contact.RecordType), but to no avail.
I'm also trying to automatically link the new Contact with the referrer Contact, and trying to pre-populate the Account ID.
 
Thank you for your help,
Jeff

 
Hi,

I have a formula field named Contract End Date and the value of this field should be calucated based on Contract Start Date and the Contract Duration. Contract Start Date is of type Date and Contract Duration is the number of months. Id I just add both the fields it considers Contract Duration as number of days instead of month. How do I achieve this?

Thanks
Jina