// enter your customized code here
Forms.Billing.BillingForm billingForm = (Forms.Billing.BillingForm)clickedButton.Form;
string peppol_response = Api.StrExtract(billingForm.BillingEngine.PiedsVRecord.PEPPOL_RESPONSE, "<CodaBox>", "</CodaBox>");
if (peppol_response == "")
{
    MercatorUi.Dialogs.Stop("Dit document is nooit naar het Peppol-netwerk gestuurd");
    return;
}
Forms.Billing.BillingCodaBox.Classes.UploadStatus status = Api.JsonConvertDeserializeObject<Forms.Billing.BillingCodaBox.Classes.UploadStatus>(peppol_response);
Forms.Billing.BillingCodaBox.CodaBox codaBox = new Forms.Billing.BillingCodaBox.CodaBox();
status = codaBox.GetStatus(status.id);
if (status == null)
    Dialogs.Stop(codaBox.Errors.ToString());
else
    Dialogs.Stop("Status = " + (status.sent_state == null ? "Onbepaald" : status.sent_state) + (!string.IsNullOrEmpty(status.sent_reason_state) ? "\r\n" + status.sent_reason_state : ""));