showstuff11
18th March 2016, 08:53
Hi guys,
We encountered an error in LN UI.(Please see attached screenshot). In LN Studio Development, the code is perfectly working. I already read some forums about the error and the explanation is, in LN Studio Development - it access only the your local server and in LN UI - it access the server. Is there any way / code same function of seq.open.dialog.local and start.application.local for LN UI?
Thanks in Advance :),
Tambor
Ajesh
18th March 2016, 11:55
Have you included the library ?#include <bic_desktop>
showstuff11
18th March 2016, 12:07
Hi Ajesh,
Yes. It's already in my code.
Tambor.
andreas.toepper
18th March 2016, 13:38
The classic client-Access functions are deprecated when using WebUI (like create.local.file()). With LNUI (HTML UI) even more restrictions have been introduced.
Please check the latest Infor ERP Enterprise Programmers Guide. You'll find a chapter named "Implementing HTML UI support". Infor introduced a bunch of new client-access-functions which will work only when using LNUI:
"HTMLUI client functions
The following functions have to be used when the client runs in HTMLUI mode:
Single file functions:
client.upload.file
client.download.file
client.show.file
Multiple file functions:
client.prepare.download
client.add.download.file
client.start.download
client.upload.files
client.get.upload.filecount()
client.get.upload.file
client.delete.upload.file.object
Assisting functions:
get.ui.mode()
tc.is.html.ui()
tc.is.thin.client()
client.get.media.type "
We're on LN 10.2.1, so I can't use those functions (10.2.1 doesn't support LNUI). But we will have a LN 10.4 testinstallation with Mingle and LNUI in some weeks.
Check Infor KB 22924522 for the latest programmers guide.
Ajesh
26th September 2016, 12:00
So which exact HTML UI/Mingle function is there for seq.open.dialog.local?
Is it client.show.file? and if yes then what are the parameters in it?
andreas.toepper
26th September 2016, 13:05
As far as I can tell (we're still not using LN UI) there is no real replacement. LN UI is based on HTML5 and therefore it is bound to the security boundaries of the browser. The browser won't let a server access a file directly on a client computer. I still don't know how to reprogram my usual fileaccess routines (i.e. when importing local stored data in LN).
I've downloaded the Programmers Guide of LN 10.5 from KB 22924522 and searched it for usefull information. There is a chapter named "Implementing HTML UI support". There you find information on the unsorported and new functions as of LN 10.4.
I think I'm going for client.upload.file and/or client.download.file. But I have to wait till the dev. environment with ming.le is running properly (it still doesn't).
I will quote the syntax of client.show.file taken from that developers guide:
client.show.file
Syntax:
#include <bic_desktop>
function long client.show.file (string source, boolean new.window, string title [, string mime.type] [, string target] [, boolean remove.after.download])
Description
Show the server file passed in the source argument in the browser. The browser can show some file types natively in a browser window (like for example plain text and pdf files). For other file types, the browser will show a browser specific download dialog.
This function will return immediately (so will not wait until the browser window is closed or the file downloaded by the client). The optional parameter "remove.after.download" can be used to control automatic removal of the server file after the file has been downloaded by the client.
Conversion of CRLF characters is only done for text files (file extension .txt or mime.type "text/plain"). All other file types are copied in binary mode.
The mime.type can be used to indicate the file type such that the browser has the option to start the client application which is associated with this mime.type. When the mime.type is not specified, the mime.type will be determined based on the file extension of the file specified in the optional target argument. When the optional target argument is also not specified, the mime.type will be determined based on the file extension of the file specified in the source argument.
When this function is called more than once for a single UI event, only the last function call will be effective.
In case of a Document Viewer session this function may only be called after calling vwr.init() or from callback function vwr.bms.received(). In case of a Document Viewer session the following arguments are ignored: new.window, title.
This function is only supported in WebUI and LN UI.
Arguments
string source Specifies the server file which must be shown in the browser.
boolean new.window When this option is true, the server file is shown in a new browser window. Otherwise this file is shown in a frame embedded in the current browser window.
string title Specifies the title for the browser window or frame.
[string mime.type] This optional argument can be used to indicate the file type such that the browser has the option to start the plugin which is associated with this mime.type. When the mime.type is not specified, the mime.type will be determined based on the file extension of the file specified in the source argument.
[string target] optional string representing the proposed file name on the client
[boolean remove.after.download] When this optional argument is true, the file on the server is automatically removed after the file is downloaded by the client. The default value is false.
Return values
0 success
<0 when an error occured (for instance invalid source path)
Context
This function is implemented in the 4GL Engine and can be used in all script types. This function is available from TIV level 1900.
bhushanchanda
26th September 2016, 17:50
Replacement for seq.open.dialog.local() is client.upload.file() or client.upload.files() for multiple selection.
Here is a snippet which shows how you can utilize it -
function extern upload.file()
{
long id
long index
long fcount
long total
long l
id = 0
fcount = 0
index = 0
path = trim$(path)
l = len(path)
if path(l;1) = "/" then
else
path = path & "/"
endif
if tc.is.html.ui() then
id = client.upload.files(path)
if id <> 0 then
fcount = client.get.upload.filecount(id)
total = fcount
index = 1
while fcount > 0
serverfile = client.get.upload.file(id,index,filename)
serverfile = trim$(serverfile)
filename = trim$(filename)
file.mv(trim$(serverfile),trim$(path)&trim$(filename))
fcount = fcount - 1
index = index + 1
endwhile
message("%d files uploaded successfully!",total)
else
message("Uploading failed. Please check the path.")
endif
else
seq.open.dialog.local(true,"","","*.*",filename)
filename = trim$(filename)
while not isspace(filename)
find = 0
found = 0
find = rpos(filename,"\")
serverfile = filename(find+1;len(filename)-find)
ret = client2server(filename,trim$(path)&serverfile,false,false,true)
if ret = 0 then
else
message("File transfer failed for %s",filename)
endif
filename = ""
seq.open.dialog.next(filename)
endwhile
endif
}
Offcourse, HTML5 has restrictions over other functions which doesn't involve user interaction like client2server(), start.application.local() etc but you can always have an option for file selector.
Regarding the function client.show.file(), it can be used to open a file directly on client machine. Again, only the files(MIME Types) supported by your browser will be opened . Else it will ask for a default program to open it. Here goes a sample code -
file.pntr = client.show.file(
"/home/" & trim$(bhushan) & "/Sample_Report.pdf",
true, |Opens a new window
"Sample Report.pdf" |Name of the report to be shown
)
andreas.toepper
27th September 2016, 09:31
Many thanks for the examples!
Ajesh
27th September 2016, 10:17
I am using the below code
if tc.is.html.ui() then
message("Loop entering")
ret = client.upload.files(form.path)
if ret<> 0 then
server.file.name = client.get.upload.file(ret,1,file.name)
message("Form Path:%s,File Name:%s",form.path,file.name)
else
message("Uploading failed. Please check the path.")
endif
else
ret = seq.open.dialog.local(true,"", form.path,"*.*",file.name)
if ret >0 then
form.path = strip$(file.name)
endif
endif
But the file is not getting uploaded. BTW, the form.path is blank at the stage when the file is getting uploaded.
Any Documentation available for these commands?
bhushanchanda
27th September 2016, 11:12
Hi,
You cannot leave form.path blank. Its the destination path.
client.upload.files()
#include <bic_desktop>
function long client.upload.files (string destination)
Description
Upload one or more files from the client and save these files in a server directory. Conversion of CRLF characters is only done for text files (file extension .txt or mime.type "text/plain"). All other file types are copied in binary mode. This function returns an id that can be used in the function client.get.upload.file to obtain information of an uploaded file. This function is only supported for HTMLUI.
Arguments
string destination the file on the server to which the client file will be uploaded (user must have write permission).
Return values
<>0 the id of the result object to be used by subsequent functions. This result object must be deleted using the function: client.delete.upload.file.object
0 when an error occurred (for instance destination is a directory)
client.upload.file()
#include <bic_desktop>
function long client.upload.file (string destination [, ref string client.filename] [, ref string mime.type])
Description
Upload a single file from the client and save this file on the server in the file location passed as the destination argument. Conversion of CRLF characters is only done for text files (file extension .txt or mime.type "text/plain"). All other file types are copied in binary mode. This function is only supported for HTMLUI.
Arguments
string destination the file on the server to which the client file will be uploaded (user must have write permission).
[ref string client.filename] the original name of this file on the client
[ref string mime.type] optional string representing the MIME Media type of the file. The official list can be found here: http://www.iana.org/assignments/media-types/index.html.
Return values
0 success
<0 when an error occurred (for instance destination is a directory)
client.get.upload.file()
#include <bic_desktop>
function string client.get.upload.file (long id, long index [, ref string client.filename] [, ref string mime.type])
Description
Get the details about a file which is uploaded with function client.upload.files. This function is only supported for HTMLUI.
Arguments
long id the id of the result object returned by client.upload.files.
long index one-based index of the uploaded file for which the information is requested.
[ref string client.filename] the original name of this file on the client.
[ref string mime.type] optional string representing the MIME Media type of the file. The official list can be found here: http://www.iana.org/assignments/media-types/index.html.
Return values
The server path name of the uploaded file or empty when an error occurred
Ajesh
27th September 2016, 13:25
And how do we get the Client Location from the Web UI? For example "c:\Users\Desktop\Import", i need to get this value in the script.....
bhushanchanda
27th September 2016, 13:53
Hi,
client.get.upload.file (long id, long index [, ref string client.filename]) gives you the file name but it won't give you the directory name, again, due to security issues. And, AFAIK, you won't need directory name to do the uploading.
get.client.directory() was marked as untrusted and hence doesn't work with LNUI.
dhruv_x0
16th February 2017, 16:25
Hi All,
I can't see any function for deleting the Local file also from LN UI? Is there any alternative?
Thanks
bhushanchanda
16th February 2017, 16:34
No. You can't do that directly through LN without user intervention. HTML 5 does not allow any client side automation.
What you can probably do is, write a simple bat file on server which has commands to delete X file. Now, send that file for downloading on users machine and let user run it. Once he runs it, the file will be deleted. I don't think there is any direct simpler way.