You need to sign in to do that
Don't have an account?

hi .The creator(Owner of the opportunity) will get copied to Initial Owner field.
.The creator(Owner of the opportunity) will get copied to Initial Owner field. for trigger pls give that code
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
.The creator(Owner of the opportunity) will get copied to Initial Owner field. for trigger pls give that code
is Initial Owner field is a custom field of opportunity? if yes, what is the API name of it? and
when you want to copy owner of opportunity to Initial Owner field?
at the time of insert or update or both?
Hi Suresh,
Apex Trigger:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
Its fine working get id record and one more thing need test class for this one pls .................. iam new converted siebel to sales force iam not understand pls give that code pls..........................
trigger ValidateAmountValueAndTotalamount on Opportunity ( before insert, before update ) {
for ( Opportunity opp : Trigger.new )
{
if(opp.name!=null)
{
user usr=[select id,name from user where id =: opp.ownerid];
opp.Owner_field__c=usr.name;
String CSDRid= [Select Id from RecordType where RecordType.Name='Sales Opportunity-CSD'].Id;
if(opp.Stagename == 'New Opportunity' && opp.Probability == 10 && opp.RecordTypeId==CSDRid)
{
if(opp.Amount == null)
{
opp.Amount.addError('****enter something yar****');
}
if ( opp.Total_Amount__c == null )
{
opp.Total_Amount__c.addError( 'Please enter a value Total Amount.' );
}
}
Hi Suresh,
Below is the test class for your trigger.
Apex Trigger:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
trigger ValidateAmountValueAndTotalamount on Opportunity ( before insert, before update )
{
for ( Opportunity opp : Trigger.new )
{
if(opp.name!=null)
{
user usr=[select id,name from user where id =: opp.ownerid];
opp.Owner_field__c=usr.name;
String CSDRid= [Select Id from RecordType where RecordType.Name='Sales Opportunity-CSD'].Id;
if(opp.Stagename == 'New Opportunity' && opp.Probability == 10 && opp.RecordTypeId==CSDRid)
{
if(opp.Amount == null)
{
opp.Amount.addError('****enter something yar****');
}
if ( opp.Total_Amount__c == null )
{
opp.Total_Amount__c.addError( 'Please enter a value Total Amount.' );
}
}
else if ( opp.StageName == 'Qualification' && opp.Probability == 10 && opp.RecordTypeId==CSDRid)
{
if ( opp.Amount == null )
{
opp.Amount.addError( 'Please********** ' );
}
if ( opp.Total_Amount__c == null )
{
opp.Total_Amount__c.addError( 'Please enter a value Total Amount****.' );
}
}
else if ( opp.StageName == 'Value Proposition' && opp.Probability == 50 && opp.RecordTypeId==CSDRid )
{
if ( opp.Amount == null )
{
opp.Amount.addError( 'only stars**********.' );
}
if ( opp.Total_Amount__c == null )
{
opp.Total_Amount__c.addError( 'here also ***********' );
}
}
else if ( opp.StageName == 'Prospecting' && opp.Probability == 10 && opp.RecordTypeId==CSDRid )
{
if(opp.Two_Year_Revenue__c == 0)
{
opp.Two_Year_Revenue__c.addError( 'Please enter a Two_Year_Revenue__c.' );
}
if(opp.customer_Quotation_Date__c == null)
{
opp.customer_Quotation_Date__c.addError( 'Please enter a customer_Quotation_Date__c.' );
}
if ( opp.Amount == null )
{
opp.Amount.addError( '@@@@@@@@@@@@@Please enter a Amount.' );
}
if ( opp.Total_Amount__c == null )
{
opp.Total_Amount__c.addError( '@@@@@@@@@@@@Please enter a value Total Amount.' );
}
}
}
}
}
you have to create new apex class which i have given to you.
and insert more opportunity test record in that class as per your different conditions.