Here I'm using the OnAfterInsertEvent trigger which always fires after even getting the single data from row and send it to my methods which resulted in getting the error all the time. I want to use some other trigger or thing that can only be fired when all data of row has been inserted or you can say when user complete it's insertion on working row.
[EventSubscriber(ObjectType::Table, Database::"Arm_Vendor Insurance", 'OnAfterInsertEvent', '', true, true)]
local procedure VendorInsuranceInsertCheck(var Rec: Record "Arm_Vendor Insurance"; RunTrigger: Boolean)
var
JsonString: Text;
ApiMgtCodeunit: Codeunit ApiMgt_Codeunit;
Vendor: Record Vendor;
IntInsuranceReq: Integer;
begin
Vendor.SetRange(Vendor."No.", Rec."Vendor No.");
if Vendor.FindFirst() and Vendor."Link With BuilderMT" then begin
JsonString := '{"subNavNumber":"' + Rec."Vendor No." + '","lineNo":' + Format(Rec."Line No.") + ',"insuranceTypeCode":"AUTO","insuranceRequired":0,"policyNumber":"' + Rec."Policy Number" + '","policyStartDate":"' + Format(Rec."Policy Start Date") + '","policyExpirationDate":"' + Format(Rec."Policy Expiration Date") + '","insuranceCompanyName":"' + rec."Insurance Company Name" + '","insuranceContactName":"' + rec."Insurance Contact Name" + '","insuranceContactPhoneNo":"' + rec."Insurance Contact Phone No." + '","coverageamount":' + Format(rec."Coverage Amount") + ',"createddatetime":"","createdby":"{00000000-0000-","updateddatetime":"","updatedby":"{00000000-0000-","isActive":true}';
ApiMgtCodeunit.GetInsuranceDetails(JsonString);
end;
end;