You need to sign in to do that
Don't have an account?
k practice
URGENT:More than one contact in an object how to display error message using standard button?
Hi,
I tried like below but its not working
BUTTON CODE:
----------
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}
var result = sforce.apex.execute('MyClass', 'myMethod', {Accountid:'{!Account.Id}'});
Alert('More than one contact not allowed'+result);
Class:
======
webService static String myMethod(ID Accountid) {
String BusinessAccountid = Businessaccount.id;
String Errorstring='More than one contact not allowed';
List<Contact> checkBusinessAccountContactList=[SELECT id FROM Contact WHERE Accountid = :BusinessAccountid];
System.debug(checkBusinessAccountContactList);
Account BusinessAccountrelatedContacts=new Account();
if(checkBusinessAccountContactList.size() > 1)
{
return Errorstring;
}
}
help me..
I tried like below but its not working
BUTTON CODE:
----------
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}
var result = sforce.apex.execute('MyClass', 'myMethod', {Accountid:'{!Account.Id}'});
Alert('More than one contact not allowed'+result);
Class:
======
webService static String myMethod(ID Accountid) {
String BusinessAccountid = Businessaccount.id;
String Errorstring='More than one contact not allowed';
List<Contact> checkBusinessAccountContactList=[SELECT id FROM Contact WHERE Accountid = :BusinessAccountid];
System.debug(checkBusinessAccountContactList);
Account BusinessAccountrelatedContacts=new Account();
if(checkBusinessAccountContactList.size() > 1)
{
return Errorstring;
}
}
help me..
All Answers
Actually i try to convert Business account to Personal account using button.When user click this button it will check Contacts in business account.Suppose contacts more than one in Business account i will through an error.
1)Businessaccount.id-->This is Accountid(I passed in Button creation time that id)
2)I get Error but its displaying every time
3)When this conditon will reach its not goto next line
please help me..
Button Code Class Code
How to stop error message 1 contact time..
How to check result variable?
Before i asked one question you know .I deleted you know please help me...
Here i was getting Contact object Custom fields.If suppose one custom field is not there in below comparing object(Person object).How to avoid this custom fields and same fields how to update?
for (Schema.SObjectField objField: Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap().values()) {
DescribeFieldResult fr = objField.getDescribe();
if (fr.isUpdateable()) //isCreateable())
{
if (fr.getName().endsWith('__c')) {
String str = fr.getName();
String contactcustomFields = str.replaceAll('__c', '__pc');
System.debug(contactcustomFields);
pAccount.put(contactcustomFields, Ocontact.get(str));
//update pAccount;
System.debug(pAccount.put(contactcustomFields, Ocontact.get(str)));
}
}
}
Help me.....