@@ -252,6 +252,7 @@ page 7775 "Copilot AI Capabilities"
252
252
EnvironmentInformation: Codeunit "Environment Information";
253
253
WithinGeo: Boolean ;
254
254
WithinEUDB: Boolean ;
255
+ TaskId: Integer ;
255
256
begin
256
257
OnRegisterCopilotCapability() ;
257
258
@@ -280,7 +281,43 @@ page 7775 "Copilot AI Capabilities"
280
281
281
282
if EnvironmentInformation. IsSaaSInfrastructure() then begin
282
283
CopilotNotifications. ShowBillingInTheFutureNotification() ;
283
- CopilotNotifications. CheckAIQuotaAndShowNotification() ;
284
+ CurrPage. EnqueueBackgroundTask( TaskId, Codeunit ::"Copilot Quota Impl.") ;
285
+ end ;
286
+ end ;
287
+
288
+ trigger OnPageBackgroundTaskCompleted( TaskId: Integer ; Results: Dictionary of [Text , Text ])
289
+ var
290
+ CopilotNotifications: Codeunit "Copilot Notifications";
291
+ Value : Text ;
292
+ CanConsume: Boolean ;
293
+ HasBilling: Boolean ;
294
+ QuotaUsedPercentage: Decimal ;
295
+ CanConsumeLbl: Label ' CanConsume' , Locked = true;
296
+ HasSetupBillingLbl: Label ' HasSetupBilling' , Locked = true;
297
+ QuotaUsedPercentageLbl: Label ' QuotaUsedPercentage' , Locked = true;
298
+ begin
299
+ if Results. ContainsKey( CanConsumeLbl) then begin
300
+ Results. Get( CanConsumeLbl, Value ) ;
301
+ if Evaluate( CanConsume, Value ) then ;
302
+ if not CanConsume then begin
303
+ CopilotNotifications. ShowAIQuotaUsedUpNotification() ;
304
+ exit ;
305
+ end ;
306
+ end ;
307
+
308
+ if Results. ContainsKey( HasSetupBillingLbl) then begin
309
+ Results. Get( HasSetupBillingLbl, Value ) ;
310
+ if Evaluate( HasBilling, Value ) then ;
311
+ if HasBilling then
312
+ exit ;
313
+ end ;
314
+
315
+ if Results. ContainsKey( QuotaUsedPercentageLbl) then begin
316
+ Results. Get( QuotaUsedPercentageLbl, Value ) ;
317
+ if Evaluate( QuotaUsedPercentage, Value ) then ;
318
+ if QuotaUsedPercentage >= 80.0 then
319
+ CopilotNotifications. ShowAIQuotaNearlyUsedUpNotification() ;
320
+ exit ;
284
321
end ;
285
322
end ;
286
323
0 commit comments