internal final class TestButtonClass{ [FormControlEventHandler(formControlStr(MOVendorPayment, TestButton), FormControlEventType::Clicked)] public static void TestButton_OnClicked(FormControl sender, FormControlEventArgs e) { // Get the current record from the header data source FormDataSource headerDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentHeaderTable)); FormDataSource linesDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentLinesTable)); if (headerDS && linesDS) { // Get the header record MOVendorPaymentHeaderTable headerRecord = headerDS.cursor(); // Create a string to hold line data str linesData = //; int numLines = 0; // Create an IntegrationLog instance for each line while (linesDS.next()) { MOVendorPaymentLinesTable linesRecord = linesDS.cursor(); // Add each line's data to the string str lineData = strFmt( /{///voucher///:///%1///,///LineNum///:///%2///,///Currency///:///%3///}/, linesRecord.voucher, linesRecord.LineNum, linesRecord.Currency ); if (numLines > 0) { linesData += /,/; } linesData += lineData; // Increment the line count numLines++; } // Combine header and lines data into a single JSON request str requestContent = strFmt('{/JournalBatchNumber/:/%1/,/Description/:/%2/,/NumOfLines/:/%3/,/LinesData/:[%4]}', headerRecord.JournalBatchNumber, headerRecord.Description, headerRecord.NumofLines, // Use numLines instead of headerRecord.NumofLines linesData); // Log the combined request info(strFmt(/Combined Request: %1/, requestContent)); // Make the API call with the combined requestContent (assuming your API call is correct) var response = VendPaymentAPI.VendPayment.Helper::PostActivity(requestContent, https://TestAPIsalesforce/api/Ref//); info(/Payment Instructions sent to Bank, Pending Approval, BankTest/); } else { error(/No header or lines record selected./); } }}
[FormControlEventHandler(formControlStr(MOVendorPayment, BankSend), FormControlEventType::Clicked)]
public static void BankSend_OnClicked(FormControl sender, FormControlEventArgs e)
{
// Get the current record from the header data source
FormDataSource headerDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentHeaderTable));
FormDataSource linesDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentLinesTable));
if (headerDS && linesDS)
{
int numLines = 0;
// Create an IntegrationLog instance for each line
while (linesDS.next())
{
MOVendorPaymentLinesTable linesRecord = linesDS.cursor();
numLines++;
}
}
else
{
error("No header or lines record selected.");
}
}
MOVendorPaymentLinesTable paymentLine = selectionHelper.getFirst();
while (paymentLine.RecId)
{
paymentLine = selectionHelper.getNext();
}
internal final class BankSend
{
[FormControlEventHandler(formControlStr(MOVendorPayment, BankSend), FormControlEventType::Clicked)]
public static void BankSend_OnClicked(FormControl sender, FormControlEventArgs e)
{
// Get the current record from the header data source
FormDataSource headerDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentHeaderTable));
FormDataSource linesDS = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentLinesTable));
if (headerDS && linesDS)
{
// Get the header record
MOVendorPaymentHeaderTable headerRecord = headerDS.cursor();
// Create a string to hold line data
str linesData = "";
int numLines = 0;
// Create an IntegrationLog instance for each line
while (linesDS.next())
{
MOVendorPaymentLinesTable linesRecord = linesDS.cursor();
// Add each line's data to the string
str lineData = strFmt(
"{\"voucher\":\"%1\",\"LineNum\":\"%2\",\"Currency\":\"%3\",\"Amount\":\"%4\",\"DateTrans\":\"%5\",\"Description\":\"%6\",\"VendorName\":\"%7\",\"VendorBankAccountName\":\"%8\",\"VendorBankAccountNumber\":\"%9\",\"VendorBankAccountAddress\":\"%10\",\"CountryCode\":\"%11\",\"CountryName\":\"%12\",\"RoutingNumber\":\"%13\",\"SwiftCode\":\"%14\",\"ChargeBeneficiary\":\"%15\",\"HasIntermediary\":\"%16\",\"IntermediaryAccountNumber\":\"%17\",\"IntermediaryBankName\":\"%18\",\"IntermediaryBankAddress\":\"%19\",\"IntermediarySortCode\":\"%20\",\"IntermediarySwiftCode\":\"%21\",\"SourceAccount\":\"%22\",\"PaymentReference\":\"%23\"}",
linesRecord.voucher,
linesRecord.LineNum,
linesRecord.Currency,
linesRecord.Amount,
linesRecord.DateTrans,
linesRecord.Description,
linesRecord.VendorName,
linesRecord.VendorBankAccountName,
linesRecord.VendorBankAccountNumber,
linesRecord.VendorBankAccountAddress,
linesRecord.CountryCode,
linesRecord.CountryName,
linesRecord.RoutingNumber,
linesRecord.SwiftCode,
linesRecord.ChargeBeneficiary,
linesRecord.HasIntermediary,
linesRecord.IntermediaryAccountNumber,
linesRecord.IntermediaryBankName,
linesRecord.IntermediaryBankAddress,
linesRecord.IntermediarySortCode,
linesRecord.IntermediarySwiftCode,
linesRecord.SourceAccount,
linesRecord.PaymentReference
);
if (numLines > 0)
{
linesData += ",";
}
linesData += lineData;
// Create a new IntegrationLog record for each line
IntegrationLog integrationLog;
integrationLog.initValue();
// Populate IntegrationLog fields with data from Lines
integrationLog.Currency = linesRecord.Currency;
integrationLog.Amount = linesRecord.Amount;
integrationLog.DateTrans = linesRecord.DateTrans;
integrationLog.Description = linesRecord.Description;
integrationLog.CountryCode = linesRecord.CountryCode;
integrationLog.HasIntermediary = linesRecord.HasIntermediary;
integrationLog.ChargeBeneficiary = linesRecord.ChargeBeneficiary;
integrationLog.IntermediaryAccountNumber = linesRecord.IntermediaryAccountNumber;
integrationLog.VendorName = linesRecord.VendorName;
integrationLog.RoutingNumber = linesRecord.RoutingNumber;
integrationLog.SwiftCode = linesRecord.SwiftCode;
integrationLog.IntermediaryBankAddress = linesRecord.IntermediaryBankAddress;
integrationLog.IntermediaryBankName = linesRecord.IntermediaryBankName;
integrationLog.IntermediarySortCode = linesRecord.IntermediarySortCode;
integrationLog.IntermediarySwiftCode = linesRecord.IntermediarySwiftCode;
integrationLog.PaymentReference = linesRecord.PaymentReference;
integrationLog.JournalBatchNumber = linesRecord.JournalBatchNumber;
integrationLog.voucher = linesRecord.voucher;
integrationLog.LineNum = linesRecord.LineNum;
integrationLog.VendorBankAccountName = linesRecord.VendorBankAccountName;
integrationLog.VendorBankAccountNumber = linesRecord.VendorBankAccountNumber;
integrationLog.VendorBankAccountAddress = linesRecord.VendorBankAccountAddress;
// Save the IntegrationLog record
integrationLog.insert();
// Increment the line count
numLines++;
}
// Combine header and lines data into a single JSON request
str requestContent = strFmt('{"JournalBatchNumber":"%1","Description":"%2","NumOfLines":"%3","PaymentGateway":"%4","JournalBalance":"%5","VendorPaymentType":"%6","LinesData":[%7]}',
headerRecord.JournalBatchNumber,
headerRecord.Description,
numLines,
headerRecord.PaymentGateway,
headerRecord.JournalBalance,
headerRecord.VendorPaymentType,
linesData);
// Log the combined request
info(strFmt("Combined Request: %1", requestContent));
// Make the API call with the combined requestContent (assuming your API call is correct)
var response = VendPaymentAPI.VendPayment.Helper::PostActivity(requestContent, "https://TestAPIsalesforce/api/Ref//");
info("Payment Instructions sent to Bank, Pending Approval, BankTest");
}
else
{
error("No header or lines record selected.");
}
}
[FormControlEventHandler(formControlStr(MOVendorPayment, BankSend), FormControlEventType::Clicked)]
public static void Ok_OnClicked(FormControl sender, FormControlEventArgs e)
{
// Get the current record from the data source
MOVendorPaymentHeaderTable movVendorPaymentHeaderTable = sender.formRun().dataSource(formDataSourceStr(MOVendorPayment, MOVendorPaymentHeaderTable)).cursor();
if (movVendorPaymentHeaderTable)
{
ttsbegin;
movVendorPaymentHeaderTable.VendPaymentApprovalStatus = VendPaymentApprovalStatus::Sent;
movVendorPaymentHeaderTable.update();
ttscommit;
info("Payment has been sent");
}
else
{
info("Payment cannot be recalled.");
}
}
}
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156