dbr.import question

(18 posts) (3 voices)
  1. eugfri, Member

    hello,

    I have searched all forums and studied demos on anything that I could find pertaining to dbr.import but still was not able to find much help.
    The functionality I am trying to implement is probably very common so hopefully this thread will be useful to many.

    I would like to give user an option to select some parameters that would be defaults for some column values while importing data file. I have vanilla import working with dbr.import.prepare proc and dbr.import proc. In dbr.import.prepare I create my staging table and in dbr.import I populate it.

    But I would like to:
    a) pass my user selected parameters to dbr.import to be used for inserting into columns
    b) be able to validate uploaded data, detect invalid rows and be able to show some output to the user allowing him to decide whether to proceed or cancel import.

    Is there way to implement a) and b) by means of dbr.import functionality?

    Thank you!
    Eugene

  2. eugfri, Member

    If you could possibly make some sample with dbr.import part of your general product demo on the site - it would be greatly appreciated!

  3. myDBR Team, Key Master

    To pass user selected parameters into the import, you can use 'extra_columns', import option. Alternatively, you can pass them in dbr.import.prepare or dbr.import.finish as parameters.

    To validate uploaded data you have two options. Do the validation row by row in the import_procedure or do it all in once in dbr.import.finish.

    --
    myDBR Team

  4. eugfri, Member

    I see, thank you!
    And what if I would like to get user input upon presenting validation results - whether to proceed and actually ingest the data or abort the process, what dbr procedure can I use?
    I have figured dbr.button might have been a possible solution, but this is just a single button visually, its not a choice b/w "Proceed" and "Cancel" options.
    If I use two different dbr.button(s), is there way to place them visually next to each other, not one under another?

  5. myDBR Team, Key Master

    You can set two buttons one of Proceed and one for Cancel. To place the buttons side by side, use dbr.keepwithnext.

    --
    myDBR Team

  6. eugfri, Member

    Thank you!
    Maybe one last question on the subject.
    If i do my dbr.import and I have select from my resulting table all inside of my report, so user can see what exactly he has uploaded - the issue I have is that dbr.import works perfectly fine, all validations work etc, but I can't seem to find the way to force refresh screen, so under "upload file" dialog box I can show results of my select from table with uploaded data.
    I have tried adding dbr.refresh but it does not seem do just a single refresh, rather it forces periodic refresh even with no parameters.

    Here is my code:

    select 'dbr.editable', '[Description]', 'sp_DBR_UploadVendorItems_edit_descr', 'vID=ID', 'type=autosize'; select 'dbr.editable', '[PartNumber]', 'sp_DBR_UploadVendorItems_edit_partno', 'vID=ID', 'type=autosize'; select 'dbr.editable', '[Mfg]', 'sp_DBR_UploadVendorItems_edit_mfg', 'vID=ID', 'type=select', "select=select distinct mfg from ssn.VendorItems"; select 'dbr.editable', '[Cond]', 'sp_DBR_UploadVendorItems_edit_cond', 'vID=ID', 'type=select', "select=select distinct destval from ssn.xref where dest='SSN' and domain='Condition'"; select 'dbr.editable', '[Qty]', 'sp_DBR_UploadVendorItems_edit_qty', 'vID=ID', 'type=autosize'; select 'dbr.editable', '[PriceUSD]', 'sp_DBR_UploadVendorItems_edit_prusd', 'vID=ID', 'type=autosize'; select 'dbr.editable', '[PriceEUR]', 'sp_DBR_UploadVendorItems_edit_preur', 'vID=ID', 'type=autosize'; select 'dbr.javascript', "function confirmdel(obj) {return confirm('Delete item \\''+$(obj).parent().children().eq(2).text()+'\\'?');}"; select 'dbr.report', 'sp_DBR_UploadVendorItems_del', '[del]', 'hiddendiv', 'inID=ID', 'event=click', 'callbefore=confirmdel';

    select 'dbr.import.options', 'skip_header', 1; /* Treat first line as header and skip it */ select 'dbr.import.options', 'extra_columns', vSelectedVendor; select 'dbr.import', 'sp_DBR_UploadVendorItems_do'; select 'dbr.import.finish', 'sp_DBR_UploadVendorItems_finish';

    select ID, VendorName, Description, PartNumber, Mfg, Cond, Qty, PriceUSD, PriceEUR, 'dbr.purehtml:<div class="i_delete"></div>' as '[del]' from ssn.VendorItemsUpload;

    select 'dbr.keepwithnext'; select 'dbr.embed_object', 'saved'; select 'dbr.embed_object', 'cancelled';

    select 'dbr.keepwithnext'; select 'dbr.button', 'Save'; select 'dbr.report', 'sp_DBR_UploadVendorItems_save', 'saved'; select 'dummy';

    select 'dbr.button','Cancel'; select 'dbr.report', 'sp_DBR_UploadVendorItems_cancel', 'cancelled'; select 'dummy';

  7. myDBR Team, Key Master

    For now you have to refresh manually (either using browsers refresh or by adding refresh button to the report).

    We'll add a way to pass JavaScript from import.finish. This would allow to import.finish to initiate a callback.

    --
    myDBR Team

  8. eugfri, Member

    May I also ask to allow to "hang" javascript on dbr.button? it would be very helpful as well!

  9. myDBR Team, Key Master

    Can you give an example of this?

    --
    myDBR Team

  10. eugfri, Member

    Sure.
    For example, if I make editable table/report I can "hang" javascript callback on the column:

    select 'dbr.javascript', "function confirmdel(obj) {return confirm('Delete item \\''+$(obj).parent().children().eq(2).text()+'\\'?');}"; select 'dbr.report', 'sp_DBR_UploadVendorItems_del', '[del]', 'hiddendiv', 'inID=ID', 'event=click', 'callbefore=confirmdel';

    However, when I try to have similar callback hookup using button and not column:
    select 'dbr.javascript', "function myfunction() { ....};"; select 'dbr.button', 'Save'; select 'dbr.report', 'sp_DBR_UploadVendorItems_save', 'saved', 'event=click', 'callafter=myfunction()';
    it is not available.

    This would be great addition to the functionality you already have and would give a lot of flexibility in implementing buttons.

  11. myDBR Team, Key Master

    You can return dbr.javascript from the sp_DBR_UploadVendorItems_save and it will work like your callafter would.

    Btw, no need to use event=click with buttons (if it was not just copy and paste),
    --
    myDBR Team

  12. eugfri, Member

    Are you saying that
    select 'dbr.javascript', "function myfunction() { ....};";
    can be last statement in my sp_DBR_UploadVendorItems_save stored procedure and effectively it would work as a callback?

    if yes, I suppose I can do the same in my dbr.import.finish stored procedure and have javascript function to do page force-refresh. Would that work?

  13. myDBR Team, Key Master

    What you would do is that you put the actual JavaScript function declaration into the main report so you can call it anywhere. If you want to call the function from the sp_DBR_UploadVendorItems_save, you just add code:

    select 'dbr.javascript', 'myfunction()'; 

    at the end of the procedure. Of course you do not need the function call at all, if you just refresh the page, you can just call location.reload().

    The dbr.import.finish procedure output is handled as text for now. We'll create a new build later this week which allows you to use JavaScript in the output as well.

    --
    myDBR Team

  14. eugfri, Member

    ok, perfect. I will try location.reaload() at the end of my sp_DBR_UploadVendorItems_save prod.
    I believe I have already tried that, but it was not refreshing the page. But let me try again.

    Thank you for the suggestion!

  15. myDBR Team, Key Master

    The dbr.import.finish output has now support for JavaScript. Just run the updater to get the latest build.

    --
    myDBR Team

  16. eugfri, Member

    Excellent!
    Thank you for your great work!

  17. chadwickhung, Member

    Hi Eugene,
    I am doing exactly the same thing and has been searching around, do you mind to share your codes with me?

    Thanks a lot

    Chadwick

  18. myDBR Team, Key Master

    Chadwick,
    there is an example of this in the documentation.

    --
    myDBR Team


Reply

You must log in to post.