Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
chris_johnson
Contributor III

Macro not running in task

Hi,

I've been having a problem (which seems to have been happening since updating to QV Nov'17 version) with running a macro. There is a macro that does some text encoding on running of the scheduled task, does not access the file system, but will only run when ran on QV Desktop not in the QV Server.

I have checked in the QMC and macro execution is allowed (although unsafe macros is not ticked).

I don't understand why the macro will not run when the server runs the task.

Anyone have any ideas?

Thanks

Tags (1)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Macro not running in task

If I understand this routine right it adjust an invalid url through replacing invalid chars into a valid url. Something like this could be done with a mapsubstring() like in this example:

Re: Passing parameter strings that contain special characters

- Marcus

View solution in original post

11 Replies

Re: Macro not running in task

Hi Adam, there is a list of macro limitations in server:

Using Macros in QV Documents on the QV-Server ‒ QlikView

Maybe is using OnPostReload trigger?

MVP & Luminary
MVP & Luminary

Re: Macro not running in task

AFAIK as a general rule no macro won't be executed by directly reloading an application through a qmc-task or starts the qmc-task an external batch/task? Are you sure it had worked before QV Nov'17?

- Marcus

chris_johnson
Contributor III

Re: Macro not running in task

It did work before the latest QV Nov'17 release, although I know that could be a coincidence. We had to upgrade due to a few other issues so could be something unrelated.

chris_johnson
Contributor III

Re: Macro not running in task

This is the VBScript function by the way:

Function URLEncode(ByVal str)

Dim strTemp, strChar

Dim intPos, intASCII

strTemp = ""

strChar = ""

For intPos = 1 To Len(str)

  intASCII = Asc(Mid(str, intPos, 1))

  If intASCII = 32 Then

   strTemp = strTemp & "+"

  ElseIf ((intASCII < 123) And (intASCII > 96)) Then

   strTemp = strTemp & Chr(intASCII)

  ElseIf ((intASCII < 91) And (intASCII > 64)) Then

   strTemp = strTemp & Chr(intASCII)

  ElseIf ((intASCII < 58) And (intASCII > 47)) Then

   strTemp = strTemp & Chr(intASCII)

  Else

   strChar = Trim(Hex(intASCII))

   If intASCII < 16 Then

    strTemp = strTemp & "%0" & strChar

   Else

    strTemp = strTemp & "%" & strChar

   End If

  End If

Next

URLEncode = strTemp

End Function

MVP & Luminary
MVP & Luminary

Re: Macro not running in task

Please provide some more informations if the qvw is directly reloaded or per external batches and how the macro is triggerred and how it does look like.

Further there was various changes on the security-settings between the releases especially if the old release was an early QV 11 then there was many changes to the current release.

- Marcus

chris_johnson
Contributor III

Re: Macro not running in task

Hi Marcus,

I posted the macro function itself to the post but it is still being moderated.

The previous release was version 12 SR 1.

The macro is triggered via a line in the script:

let urlEncoded = URLEncode('$(url)');

where url is the url for what I need to reference (a Google Analytics address) and URLEncode is the VBScript funtion

MVP & Luminary
MVP & Luminary

Re: Macro not running in task

Ok. it's a function My using of vbs-functions during the load was along time ago and probably before we extended our solution to a server-environment. Therefore I'm not really sure but if you say it worked I think vbs-functions are executed as long they not trying to access the ActiveDocument.

Therefore I could imagine that some security-setting within the settings.ini is now per default different as before but I don't know which one. It's not directly related to your case but similar from (il)logic of changing settings and may help you to get ideas: QV 12.10 “Can Execute External Programs” is back | Qlikview Cookbook.

If your vbs-routine isn't too complicated you could try to switch it into a qlikview-variable and/or a sub-routine.

- Marcus

MVP & Luminary
MVP & Luminary

Re: Macro not running in task

If I understand this routine right it adjust an invalid url through replacing invalid chars into a valid url. Something like this could be done with a mapsubstring() like in this example:

Re: Passing parameter strings that contain special characters

- Marcus

View solution in original post

Highlighted
chris_johnson
Contributor III

Re: Macro not running in task

Hi Marcus,

I switched it to script using the mapsubstring() function as you suggested (link to example I used: String manipulation)

Thanks for your help