here is Api page, I want to post, delete and modify batch entries using single api and don't want to use any filter with Api. I have entry no as primary key in table but CRM has "lead id" as primary key. tell me what the payload can be and how can implement the logic for batch insertion, deletion and updating
page 80002 "ABCAPIs"
{
APIGroup = 'ABCPortal';
APIPublisher = 'ABCPublisher';
APIVersion = 'v2.0';
ApplicationArea = All;
Caption = 'ABCAPI';
DelayedInsert = true;
EntityName = 'sdSchedules';
EntitySetName = 'sdScheduless';
PageType = API;
SourceTable = "SD Schedule";
ODataKeyFields = "Entry No";
layout
{
area(Content)
{
repeater(General)
{
field(entryNo; Rec."Entry No")
{
Caption = 'Entry No';
}
field("proposalId"; Rec."Lead Id")
{
Caption = 'Proposal Id';
}
field(sdMonths; Rec."SD Months")
{
Caption = 'SD Months';
}
field(sdDueDate; Rec."SD Due Date")
{
Caption = 'SD Due Date';
}
field(totalSDAmount; Rec."Total SD Amount")
{
Caption = 'Total SD Amount';
}
}
}
}
// actions
// {
// area(Processing)
// {
// action(BatchCreate)
// {
// ApplicationArea = All;
// Caption = 'BatchCreateSDSchedules';
// ToolTip = 'Batch create SD schedules';
// }
// }
// }
// [ServiceEnabled]
// procedure PostBatchSDSchedules(var ActionContext: WebServiceActionContext; ContentCtrl: Text): Text
// var
// BatchService: Codeunit "SDSchedule Batch Services";
// begin
// exit(BatchService.BatchCreateSDSchedules(ActionContext, ContentCtrl));
// end;
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
CustRec.SetRange("Lead Id", Rec."Lead Id");
if CustRec.FindFirst() then begin
Rec."SD Id" := CustRec."No.";
exit(true);
end;
// SDSchedule.SetRange("Entry No", Rec."Entry No");
// if SDSchedule.FindFirst() then begin
// SDSchedule."SD Due Date" := Rec."SD Due Date";
// SDSchedule."SD Months" := Rec."SD Months";
// SDSchedule."Total SD Amount" := Rec."Total SD Amount";
// SDSchedule.Modify(true);
// exit(false);
// end;
// exit(true);
SDSchedule.SetRange("Lead Id", Rec."Lead Id");
if SDSchedule.FindSet() then begin
repeat
SDSchedule."SD Due Date" := Rec."SD Due Date";
SDSchedule."SD Months" := Rec."SD Months";
SDSchedule."Total SD Amount" := Rec."Total SD Amount";
SDSchedule.Modify(true);
exit(false);
until SDSchedule.Next() = 0;
end;
exit(true);
end;
trigger OnModifyRecord(): Boolean
begin
SDSchedule.SetRange("Lead Id", Rec."Lead Id");
if SDSchedule.FindSet() then begin
repeat
SDSchedule."SD Due Date" := Rec."SD Due Date";
SDSchedule."SD Months" := Rec."SD Months";
SDSchedule."Total SD Amount" := Rec."Total SD Amount";
SDSchedule.Modify(true);
exit(true);
until SDSchedule.Next() = 0;
exit(false);
end;
end;
trigger OnDeleteRecord(): Boolean
begin
SDSchedule.SetRange("Lead Id", Rec."Lead Id");
if SDSchedule.FindSet() then begin
repeat
SDSchedule."SD Due Date" := Rec."SD Due Date";
SDSchedule."SD Months" := Rec."SD Months";
SDSchedule."Total SD Amount" := Rec."Total SD Amount";
SDSchedule.Delete(true);
exit(false);
until SDSchedule.Next() = 0;
end;
exit(true);
end;
var
SDSchedule: Record "SD Schedule";
CustRec: Record Customer;
}