Options

Dynamics NAV 2017 MediaSet

aceXaceX Member Posts: 166
edited 2017-07-10 in NAV Three Tier
Hi

I like to get the items pictures assigned in Company1 into Company2. This was easy while the Picture field in table Item was BLOB, but now when it is MediaSet I can't to find out how can I do that..
I'm trying with this code:
IF Item1.FINDFIRST THEN
REPEAT
  Item2.SETRANGE(''No'', Item1''No'');
  IF Item2.FINDFIRST THEN
  BEGIN
    Item2.CHANGECOMPANY('Company2');
    Item2.Picture := Item1.Picture;
    Item2.MODIFY;
  END;
UNTIL Item1.NEXT = 0;

but nothing happens ... also I'm trying with this:
IF Item1.FINDFIRST THEN
REPEAT
  FileNameExport := 'C:\Temp\' + FORMAT(Item1."No.") + '.jpg';
  FileNameImport := 'C:\Temp\' + FORMAT(Item1."No.") + '-1.jpg';
  Item2.SETRANGE''No'', Item1''No'');
  IF Item2.FINDFIRST THEN
  BEGIN
    Item2.CHANGECOMPANY('Company2');
    Item1.Picture.EXPORTFILE(FileNameExport);
    Item2.Picture.IMPORTFILE(FileNameImport , 'Demo Image');
  END;
UNTIL Item1.NEXT = 0;

i can't make to import the pictures in Company2 ...

Does any one know how can I transfer only Picture field from one to another company and how can I check does Picture field has value or not, for example:
IF Item1.Picture <> '' THEN ...
does this example for this is ok:
IF Item1.Picture.COUNT > 0 THEN  ...

Regards

Answers

  • Options
    DolshaDolsha Member Posts: 41
    edited 2017-07-11
    why u EXPORT 'C:\Temp\' + FORMAT(Item1."No.") + '.jpg';
    But IMPORT 'C:\Temp\' + FORMAT(Item1."No.") + '-1.jpg';
    That another name files...

    And check this: MSDN

    UPD. U can check this: IMPORTFILE function. Have nice Example for ur issue.
  • Options
    aceXaceX Member Posts: 166
    Hi there @Dolsha,

    I've already read those posts and I'm using standard examples for Import/Export file functions.
    Why I'm using different name while import is a good question. I'm doing that cause export of the image is successful and I don't know why, before the extension type while exporting I'm always get to all pictures -1. As you see I'm get the Item number for the name but when picture is exported if I don't add -1 in import function I get error that the file does not exist. When I go in C:\TEMP folder i see that pictures are exported as

    1000-1.jpg
    2001-1.jpg
    3010-1.jpg etc...

    I'm sure there must be a way to import the pictures from company into company without export and import pictures.

    Best Regards
Sign In or Register to comment.