function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JsinghJsingh 

Apex in Process Builder

Hi

When i am trying to call Apex class in Process Build using @invocablemethod it's giving following error.(the same class
i was calling using trigger also)

unsupported parameter type string.valid invocable parameters must be
List type like list where T is a supported type
 apex code is here


1
//Helper class to update customfield with autonumber field in after insert
public class updatfield
4
{
5
@InvocableMethod(Label='abc')
6
!
public static void updateoutputfield(string accountid ) //Helper class method passing one parameter
7
{
8
if(string.isNotBlank(accountid)) //check the accountid is not blank
9
{
10

11
//retrieve the value of all required field from account
12

13
Account acc=[select id , Name,Division__c, Group__c, Subgroup__c, AutoNumber__c from account where id=:accountid];
14

15
acc.Account_Number__c= acc.Division__c.substring(0,2).Touppercase()+'-'+ acc.Group__c.substring(0,2).Touppercase() + '-' + acc.Subgroup__c.substring(0,2).Touppercase() + '-'+ acc.AutoNumber__c;
16
update acc;
17

18
system.debug('Record has updated.............' + acc);
19
}
20

21
}
22
}


Trigger Code

//Trigger to update custom field Account Number on Account abject with Auto number field
trigger autonumberpopulate on Account (after insert) {
    set<Account> listOfAccount =new set<Account> ();//we want unique value that's why we are using 'set' collection 
    
    for (Account accounts: [select id, Name, Division__c,Group__c,Subgroup__c,AutoNumber__c from Account])
    {
        
        ListOfAccount.add(accounts);  //get all account id
    }
    
    for(Account newaccounts : Trigger.new) // retrieve all new accounts using for loop (bulkify)
    
    {
        
        //calling handler method updateoutputfield using handler class updatfield.
        updatfield.updateoutputfield(string.valueOf(newaccounts.id));
        

    }
}
 
Please help me

Regards
jyotsana 

 
Team NubesEliteTeam NubesElite
Hi,
public class AccountQueryAction {
  @InvocableMethod(label='Get Account Names' )
  public static List<String> getAccountNames(List<ID> ids) {
    List<String> accountNames = new List<String>();
    List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
    for (Account account : accounts) {
      accountNames.add(account.Name);
    }
    return accountNames;
  }
}

Please try like this and open your debug log and print whether your helper class is passing parameter or not.


Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this assolution if your problem resolved.