another blog


About Microsoft Dynamics GP :-)

Saving attachments by using batch file and sanscript code.

Dynamics GP 2013 is providing attachments for several windows. That’s nice to see it. 🙂

I had similar customization for Sales Transaction Entry window for multiple attachments of different type, image file, document file or text file. The attachment icons will be visible if sales order have attachments and will also be available even when orders get transferred into Invoice. For this customization we were saving attachments for sales order from some web pages.

Another window for which we do attachment work is Item Maintenance window. For this purpose we created a setup table for destination path where we save images, user could select image from anywhere and we copy that image to that particular folder so images could be access through other places or web pages.

For this purpose instead of creating any exe or .net project we use sanscript functions and batch programming.Sharing a code here.


On browse button we have this code.


Here we are calling a function where we create folder for respective item on destination path and then create a batch file to copy image file from source to destination path and afterwards delete the batch file.

function returns nothing;
in string i,ip;
out string ap4;

local string drive,p,l_Pathname,l_Returned_String,rString,a,b;
local boolean result,l_File_Error,l_Result,l_result;
local AttachmentPath ap, ap2,ap3;
local integer l_file_ID;

if empty(i) then
abort script;
end if;

if empty(ip) then
abort script;
end if;

‘Setup Key’ of table DestinationAttachmentPath=1;
get table  DestinationAttachmentPath;
if err()=OKAY then
ap=AttachmentPath of table DestinationAttachmentPath; {where we have to save file}
result = Path_DoesExist(AttachmentPath of table DestinationAttachmentPath);
end if;

if result= false then
ask(“Image destination path not setup.”,”OK”,””,””);
abort script;
end if;


{create folder for item number}
result = Path_DoesExist(ap+”\”+i);
if result=false then
ask( “Folder for item “+i+” not created.”,”OK”,””,””);
abort script;
end if;


l_file_ID = TextFile_Open(ap2, 0, 2);
TextFile_WriteLine(l_file_ID,”set ver1=”+DoubleQ+ap3+DoubleQ);
TextFile_WriteLine(l_file_ID,”set ver2=”+DoubleQ+ip+DoubleQ);
{TextFile_WriteLine(l_file_ID,”E:”); {need to set drive here}}
TextFile_WriteLine(l_file_ID,”cd %ver1%”);
TextFile_WriteLine(l_file_ID,”copy %ver2%”);
TextFile_WriteLine(l_file_ID,”del “+DoubleQ+ap2+DoubleQ);
if result=false then
end if;

run application ap2,””;




Filed under: Dexterity Development, Dynamics GP, dynamics-gp, , , ,


Enter your email address to follow this blog and receive notifications of new posts by email.

Enter your email address to follow this blog and receive notifications of new posts by email.


Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Blog Stats

  • 9,913 hits

RSS dynamics-gp

  • VSTools and database triggers.
    In SanScript coding we have database triggers, Below is a detail of what database triggers are as explained in dexterity manuals. Database triggers Database triggers are activated by successful table operations, such as a record begin read, saved, or deleted. The procedure that runs in response to a database trigger has access to the same […]
  • Getting the current active window in Dexterity.
    Using dexterity there is not a direct way of getting current active window information, but with set of available GP functions and triggers can make this task happen. Below I am sharing a trigger and function which can tell the active window name. Below code needs to be changed according to the needs of developer, […]
  • Hints and Tips… On going Post
    This is on going post and points will be added from time to time. 🙂 .. with Field Level Security we can not restrict document access on Sales transaction entry Window. Means we can not make user to choose only ‘Invoices’ in SOP Type drop down. .. we can not add custom table in table […]
  • Reversing the sort order of Receivable Transaction Inquiry – Customer by Document Date
    Last few months we got more request on changing sort orders of Inquiry windows and lookups and to cover them all in a one place I have been working on a small project which will provide a simple sorting without much effort. In Dynamics Community there was a post having similar situation, I have already […]
  • Getting the current open window in .net GP Add In
    There are many ways of getting information of active window in GP, but it changes according to the developing tool we are working on. 1.Dexterity.(the best tool 🙂
  • Not all RW_Function are meant for reports.
    There are lots of RW functions available in a report writer Calculated Field Definition window and almost all of them are so handy while working on report writer, but it is a matter of fact that some of them are not actually meant for report writer. Usually RW functions are associated with report writer and […]
  • Dexterity Can Wait and Respond.
  • Cross Dictionary Development.    
  • Calling Sales Document Numbers Lookup
    Often developers need to open available lookup on their custom form from dynamics GP.Sales Document Number lookup is a very common and much used lookup and every dynamics technical person needs to call it in once (or more) in their lifetime. 🙂 Dynamics GP SDK provide a prototype of coding on how to open various […]
  • This datatype name is already in use.
    This datatype name is already in use.
Ghostriver Studios Blog

Sculptural stained glass of Andrew Kosorok

Coding Notes

Code, News, Tech & Stuff

Dynamics GP Builders & Reporting

How to use MS Dynamics SmartList Builder, Excel Report Builder and other Reporting tools to get the data and analysis you need.

%d bloggers like this: