You need to sign in to do that
Don't have an account?
Pass variable into global class
Hi,
i've got a invocable method,
global class passbillingid {
@InvocableMethod
public static List<String> getBillingIds(List<String> names) {
List<Id> billingIds = new List<Id>();
List<AcctSeed__Billing__c> billings = [SELECT Id FROM AcctSeed__Billing__c WHERE Name in :names];
for (AcctSeed__Billing__c billing : billings) {
billingIds.add(billing.Id);
}
return billingIds;
}
}
I need to pass this variable into this global class "AcctSeed.BillingPostService.postBillings(billings)"
AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);
How can i do this inthe same invocable method?
Any help is much appreciated.
Cheers,
You can try something like this
global class passbillingid {
public static void innerMethod(List<case> billings){
AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);
}
@InvocableMethod
public static List<id> getBillingIds(List<String> names) {
List<Id> billingIds = new List<Id>();
List<case> billings = [SELECT Id FROM case WHERE id in :names];
for (case billing : billings) {
billingIds.add(billing.Id);
}
innerMethod(billings);
return billingIds;
}
}
Thanks
Ramesh
*Please mark this as best answer, so it will be helpful for others as well.*
Thank you Ramesh for your answer.
I'm getting the following error:
Compile Error: Method does not exist or incorrect signature: void postBillings(List<String>) from the type AcctSeed.BillingPostService at line 4 column 73
For reference:
// Create billing records to post and unpost
AcctSeed__Billing__c[] billings = new List <AcctSeed__Billing__c> ();
billings.add(
new AcctSeed__Billing__c(
AcctSeed__Billing_Cycle_Start_Date__c = System.today(),
AcctSeed__Billing_Cycle_End_Date__c = System.today() + 30,
AcctSeed__Date__c = System.today(),
AcctSeed__Customer__c = [Select Id From Account limit 1].Id,
AcctSeed__Status__c = 'Approved',
AcctSeed__Due_Date2__c = System.today() + 30
)
);
billings.add(
new AcctSeed__Billing__c(
AcctSeed__Billing_Cycle_Start_Date__c = System.today(),
AcctSeed__Billing_Cycle_End_Date__c = System.today() + 30,
AcctSeed__Date__c = System.today(),
AcctSeed__Customer__c = [Select Id From Account limit 1].Id,
AcctSeed__Status__c = 'Approved',
AcctSeed__Due_Date2__c = System.today() + 30
)
);
insert billings;
// Create billing line records to post
AcctSeed__Billing_Line__c[] bLines = new List <AcctSeed__Billing_Line__c> ();
AcctSeed__GL_Account__c glAccount = [Select Id From AcctSeed__GL_Account__c limit 1];
for (AcctSeed__Billing__c bill : billings) {
AcctSeed__Billing_Line__c objBillingLine = new AcctSeed__Billing_Line__c();
objBillingLine.AcctSeed__Billing__c = bill.id;
objBillingLine.AcctSeed__Date__c = System.today();
objBillingLine.AcctSeed__Rate__c = 25;
objBillingLine.AcctSeed__Hours_Units__c = 1;
objBillingLine.AcctSeed__Revenue_GL_Account__c = glAccount.Id;
bLines.add(objBillingLine);
objBillingLine = new AcctSeed__Billing_Line__c();
objBillingLine.AcctSeed__Billing__c = bill.id;
objBillingLine.AcctSeed__Date__c = System.today();
objBillingLine.AcctSeed__Rate__c = 25;
objBillingLine.AcctSeed__Hours_Units__c = 2;
objBillingLine.AcctSeed__Revenue_GL_Account__c = glAccount.Id;
bLines.add(objBillingLine);
}
insert bLines;
// Call the post billings service
AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);
// Loop through post results
for (AcctSeed.PostResult theResult : postResults) {
if (theResult.isSuccess) {
System.debug('Successfully posted billing: ' + theResult.id);
}
else {
System.debug('Error posting billing ' + theResult.id);
for (AcctSeed.PostResult.PostErrorResult errorResult: theResult.errors) {
System.debug('Error status code ' + errorResult.statusCode);
System.debug('Error message ' + errorResult.message);
}
}
}
you can pass paramter by instance of another class:-
if you fond this useful then, PLEASE MARK AS A BEST ANSWER!!
Regards
Mukesh
Possible Solution:
1) If it's not an static method, make a constructor which accepts your parameter
or
2) Initialize the class and access your method.
or
3) Make sure you pass same type of parameter to the method
Thanks
Ramesh