You need to sign in to do that
Don't have an account?
mohsin ahmad 11
have an error when executing a code in anonymous window in debug section under the developer console
When I tried to insert a record through the apex coding, I found an error :
"Line: 1, Column: 16
Invalid constructor syntax, name=value pairs can only be used for SObjects "
The code that I used was:
Account acct = new Account(
Name='SFDC Computing',
Phone='(415)555-1212',
NumberOfEmployees=50,
BillingCity='San Francisco');
insert acct;
Please tell me , why this type of error am facing??
Regards,
Mohsin Ahmad
This issue might be because of the overriding of standard controller with custom, just check in your org for any custom controller with name Account. If you find any just try renaming them to something else or delete the controller if you dont need it.
You can check by looking under Setup -> Develop -> Apex Classes, if you find any class with name Account.
Let me know if this helps.
Thanks,
Neetu
All Answers
This issue might be because of the overriding of standard controller with custom, just check in your org for any custom controller with name Account. If you find any just try renaming them to something else or delete the controller if you dont need it.
You can check by looking under Setup -> Develop -> Apex Classes, if you find any class with name Account.
Let me know if this helps.
Thanks,
Neetu
MY Code is this :
public static void updateEndDateOnAssetLineItem(List<Apttus_Config2__AssetLineItem__c> newList, Map<Id,Apttus_Config2__AssetLineItem__c> oldMap){
Set<Id> accId = new Set<Id>();
for (Apttus_Config2__AssetLineItem__c assetList : newList)
{
if((assetList .Apttus_Config2__AssetStatus__c=='Activated') && oldMap.get(assetList .Id).Apttus_Config2__AssetStatus__c!='Activated')
{
accId.add(assetList .Apttus_Config2__AccountId__c);
}
}
Map<ID, Account> accMap = new Map<ID, Account>([SELECT Id,Latest_Asset_line_item_End_date__c FROM Account where Id IN: accId]);
List<Account> accList= new List<Account>();
for (Apttus_Config2__AssetLineItem__c assetList : newList)
{
// getting error on this line.
Account acc =new Account([Select Id, Latest_Asset_line_item_End_date__c from Account where Id=: assetList.Apttus_Config2__AccountId__c]); //Type requires name=value pair construction: Account
//Account acc= new Account();
//acc.ID=[Select Id from Account where Id=: assetList.Apttus_Config2__AccountId__c];
//acc.Latest_Asset_line_item_End_date__c=[Select Latest_Asset_line_item_End_date__c from Account where Id=: assetList.Apttus_Config2__AccountId__c];
//List<Account> accList= [Select Id, Latest_Asset_line_item_End_date__c from Account where Id=: assetList.Apttus_Config2__AccountId__c];
if((assetList .Apttus_Config2__EndDate__c > accMap.get(assetList .Apttus_Config2__AccountId__c).Latest_Asset_line_item_End_date__c ||
accMap.get(assetList.Apttus_Config2__AccountId__c).Latest_Asset_line_item_End_date__c == Null) && assetList.Product_Family__c!='Trial' && assetList.Product_Family__c!='Professional Service')
{
acc.Latest_Asset_line_item_End_date__c = assetList .Apttus_Config2__EndDate__c ;
}
accList.add(acc);
}
if(accList.size()>0){
Set<Account> accset = new Set<Account>();
List<Account> resultAccList = new List<Account>();
accSet.addAll(accList);//deletes duplicates
resultAccList.addAll(accSet);//populates new list without duplicates
update resultAccList; }
}