Leave feedback
  • Question

    Update metadata on document in DocBroker+

Enter a new topic
  • Christofer Lindqvist Christofer Lindqvist StreamServe Employee
    0 likes 1710 views

    Hi,

    I need to update a metadatavalue on a document previously stored in DocBroker+.

    The scenario is as follows:

    1. An invoice is generated, invoicenumber 1234. The document is stored in DB+ with "print" and "archive" value.

    2. A creditnote is generated later on, that should credit a certain invoice, in this case invoicenumber 1234. The creditnote is stored with "print" and "archive" value.

    When the creditnote is stored i want to check if the original invoice (1234) is stored in DB+ and change the "print" value on both invoice and creditnote so they are not sent to customer, they should both still be archived. If the original invoice is not in DB+ it has already been sent out and the creditnote should also be sent out.

    So my thought was to create a PPQ immediately after the invoice is created in DB+ and with that make a lookup in the repository for the original invoice. If its found i would change the "print" value to "credited" for both invoice and creditnote. If not found, then do nothing.

    Anyone have any ideas on how to solve that?

    Regards,
    Christofer

    Tuesday 27 November, 2012
  • Shashi Prakash Shashi Prakash
    0 likes

    I have not tried this but you can try updating the table directly under StrsDocBrokerPlus Schema (or DB if SQL Server). 

    Table: dbo

     

    .cxPOST_<DocumentType>

    Tuesday 27 November, 2012
  • Tony RANNOU Tony RANNOU
    0 likes

    Hi Christofer, you have some function to modify your metadata value:

    Job Begin script:
    $ret = DeclareMetadata("zip", "N", "A");




    Post-processor Doc Begin script:
    doc_id = GetFirstSegDoc();
     SetSegMetaData($doc_id, "zip", $zip);
    SaveSegMetadata($doc_id, "city");
    Wednesday 28 November, 2012
  • Christofer Lindqvist Christofer Lindqvist StreamServe Employee
    0 likes

    Updating the DB table directly would solve the problem, but i rather not do that, instead i would like to use built in functionality, if possible.

    Tony,
    How can i say which document i want to modify?

    As i understand it the setsegmetadata and savesegmetadata only modifies itself. I want to modify another stored document (if it exists) that has the same invoicenumber as the document im currently processing.

    Regards,
    Christofer

    Wednesday 28 November, 2012
  • Stig Renberg-Larsen Stig Renberg-Larsen Partner
    0 likes

    Hi, i hope this can give you an idea...

    //postprocessor - script before job// $ret_setdeclare = DeclareMetadata("TransStatus"); //on connector - job begin script// $doc_id = GetFirstSegDoc(); while (num($doc_id) > 0) { $_TransStatus = GetSegMetadata($doc_id, "TransStatus"); log(1,"***** $_TransStatus before update = " + $_TransStatus + " *****"); if(num($_TransStatus) = 9){ $ret = SetSegMetadataNum($doc_id, "TransStatus", 1); $ret = SaveSegMetadata($doc_id, "TransStatus"); } $_TransStatus = GetSegMetadata($doc_id, "TransStatus"); log(1,"***** $_TransStatus after update = " + $_TransStatus + " *****"); $doc_id = GetNextSegDoc($doc_id); }

    //Stig ;-)

    Wednesday 28 November, 2012
  • Stig Renberg-Larsen Stig Renberg-Larsen Partner
    0 likes

     

    sorry about the formating....



    //postprocessor - script before job//
    $ret_setdeclare = DeclareMetadata("TransStatus");

    //on connector - job begin script//
    $doc_id = GetFirstSegDoc();
    while (num($doc_id) > 0) {
    $_TransStatus = GetSegMetadata($doc_id, "TransStatus");
    log(1,"***** $_TransStatus before update = " + $_TransStatus + " *****");
    if(num($_TransStatus) = 9){
    $ret = SetSegMetadataNum($doc_id, "TransStatus", 1);
    $ret = SaveSegMetadata($doc_id, "TransStatus");
    }
    $_TransStatus = GetSegMetadata($doc_id, "TransStatus");
    log(1,"***** $_TransStatus after update = " + $_TransStatus + " *****");
    $doc_id = GetNextSegDoc($doc_id);
    }

     

    Wednesday 28 November, 2012
  • Tony RANNOU Tony RANNOU
    0 likes

    hi Christopher, I implement many things with the postprocessing. you must use the default function to know if the next document is a credit note or an incoice to update or not your metadata.

    Tony

    Thursday 29 November, 2012

 

Latest from the blogs