Q:In Opportunity Records when open one Record and Click on Custom Button(ConRole),
1.it will check the any contact Role records and check the Manda troy fields,if it is ok go to next page.
2.if no records in contact role showing error message.
Procedure: 1.Go to customization> opportunity> buttons and links>click on
2.click on new button>button name>s--->>
3.Behavior = Execute Javascript and Content source=Onclick Javascript
4.copy the below code and past and save.
5.Goto>opportunity page layouts>> click on buttons>> drog conrole button and past it in custom buttons and save
==============================JavaScript====================
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var oppcontactrole = sforce.connection.query("SELECT Id, ContactId,Contact.Name,Contact.Title,Contact.MailingStreet,Contact.MailingCity,Contact.MailingState,Contact.MailingCountry,Contact.MailingPostalCode,Contact.Email FROM OpportunityContactRole where OpportunityId = '{!Opportunity.Id}'");
var contactRecord,flag=0;
var nullCheck = 'Please enter mandatory fields Title,Complete Mailing Address and Email on following contact(s)\n';
for(i=0;i<oppcontactrole.size;i++)
{
contactRecord = oppcontactrole.getArray("records")[i];
if(contactRecord.Contact.Title == null || contactRecord.Contact.MailingStreet == null || contactRecord.Contact.MailingCity == null || contactRecord.Contact.MailingState == null || contactRecord.Contact.MailingCountry == null || contactRecord.Contact.MailingPostalCode == null || contactRecord.Contact.Email == null)
{
flag = 1;
nullCheck+= contactRecord.Contact.Name+'\n';
}
}
if ( oppcontactrole.size == 0)
{
alert("You don't have contact role for related opportunity");
}
else if(flag == 1)
{
alert(nullCheck);
}
else
{
navigateToUrl("/apex/contactspage?Id={!Opportunity.Id}");
}
1.it will check the any contact Role records and check the Manda troy fields,if it is ok go to next page.
2.if no records in contact role showing error message.
Procedure: 1.Go to customization> opportunity> buttons and links>click on
2.click on new button>button name>s--->>
3.Behavior = Execute Javascript and Content source=Onclick Javascript
4.copy the below code and past and save.
5.Goto>opportunity page layouts>> click on buttons>> drog conrole button and past it in custom buttons and save
==============================JavaScript====================
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var oppcontactrole = sforce.connection.query("SELECT Id, ContactId,Contact.Name,Contact.Title,Contact.MailingStreet,Contact.MailingCity,Contact.MailingState,Contact.MailingCountry,Contact.MailingPostalCode,Contact.Email FROM OpportunityContactRole where OpportunityId = '{!Opportunity.Id}'");
var contactRecord,flag=0;
var nullCheck = 'Please enter mandatory fields Title,Complete Mailing Address and Email on following contact(s)\n';
for(i=0;i<oppcontactrole.size;i++)
{
contactRecord = oppcontactrole.getArray("records")[i];
if(contactRecord.Contact.Title == null || contactRecord.Contact.MailingStreet == null || contactRecord.Contact.MailingCity == null || contactRecord.Contact.MailingState == null || contactRecord.Contact.MailingCountry == null || contactRecord.Contact.MailingPostalCode == null || contactRecord.Contact.Email == null)
{
flag = 1;
nullCheck+= contactRecord.Contact.Name+'\n';
}
}
if ( oppcontactrole.size == 0)
{
alert("You don't have contact role for related opportunity");
}
else if(flag == 1)
{
alert(nullCheck);
}
else
{
navigateToUrl("/apex/contactspage?Id={!Opportunity.Id}");
}
No comments:
Post a Comment