You need to sign in to do that
Don't have an account?
SAHG-SFDC
Copy custom Field Values from one custom object to Opportunity
HI I am trying to copy the field values from one custom object to Opportunity standard object
I have 6 fields on Custom Object
Address, City, State, Zip Code, County and Country
I created these fields on opportunities as well
How do I copy the values? (My requirement is when users create new opportunity the system should give them option if you want to create this duplicate opportunity as the address is same (These 6 fiekds are same) and ask them if they want to create and if yes create a record
I have 6 fields on Custom Object
Address, City, State, Zip Code, County and Country
I created these fields on opportunities as well
How do I copy the values? (My requirement is when users create new opportunity the system should give them option if you want to create this duplicate opportunity as the address is same (These 6 fiekds are same) and ask them if they want to create and if yes create a record
Since you are saying that you want to give user the option to create the Opportunity duplicating the address, you're getting into a more complex process than automatically copying the field values. A Flow is the standard process to prompt Users to make a decision. If that is acceptable, you would be able to start the Flow from the existing Opportunity and present the Users with a page that displays the original Opportunity's fields' values so that they can make that choice.
Thanks for replying
Its a look up relationship, I cannot use workflows here
Duplicate opportunities are cretaed by users, If they save the new opportunity it should check for the address and if that matches it should ask them "Do you want to create new one?" or skip the creation
This is the relationship and this is the trigger
trigger OpportunityTrigger on opportunity (after insert, after update) {
// Written by shehla: To copy down the values from CP Project to Opportunity
List< ConstructionPts__CP_Project__c > listMember2ObjToInsert = new List< ConstructionPts__CP_Project__c >();
for (opportunity Oppty : Trigger.new)
{
ConstructionPts__CP_Project__c member2Obj = new ConstructionPts__CP_Project__c();
member2Obj.ConstructionPts__Address__c = Oppty.AddressContruction__c;
member2Obj.ConstructionPts__City__c = Oppty.City__c;
member2Obj.ConstructionPts__State__c = Oppty.State__c;
member2Obj.ConstructionPts__Zipcode__c = Oppty.Zip_Code__c;
member2Obj.ConstructionPts__County__c = Oppty.County__c;
member2Obj.ConstructionPts__Country__c = Oppty.Country__c;
listMember2ObjToInsert.add(member2Obj);
}
insert listMember2ObjToInsert;
}
But what you keep saying is that you want to copy the values FROM ConstructionPts__CP_Project__c and TO the Opportunity. Yet this trigger is doing the opposite. Can you clarify the goal? I thought I understood your goal, but the Trigger seems to do the opposite of what you said!
Just to rule out the obvious here, could you use Formula Fields on Opportunity? For example, for the City__c field on Opportunity, you could have a text formula with ConstructionPts__CP_Project__c.ConstructionPts__City__c as the value. You would still need to populate a lookup on Opportunities to the ConstructionPts__CP_Project__c records.
It's getting late here in NYC but I'll put up some sample code tomorrow morning if the formula idea is no good.
The opportunities are created directly by the user as new opportuity and the system should look for the address in the "ConstructionPts__CP_Project__c " with those 6 address fields if there is a match then let user decide if new opportunity should be created or skip creation