Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Read about the latest Qlik Community enhancements on the Community News blog!
cancel
Showing results for 
Search instead for 
Did you mean: 
balrammahato204
Creator
Creator

Macro not working on Post Reload from QMC

Hi All,

Please help,

Below Macro i am trying to execute after post reload trigger of the dashboard. While dashboard is reloading manually i am having proper execution. But once i am reloading the QVW file from QMC Macros are not working. 

FUNCTION ExportObjectToJpg( ObjID, fName)
ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile fName
END FUNCTION


sub Export

set obj = ActiveDocument.GetSheetObject("CH08")
obj.ExportBitmapToFile "E:\Qlikview\Image.jpg"
ActiveDocument.GetSheetObject("BU04").Press
end sub

Regards

Balram

Labels (1)
1 Solution

Accepted Solutions
balrammahato204
Creator
Creator
Author

Thanks for Response.

I have Achieved the solution using Powershell and  html codes. Also post reload trigger is working once i am triggering the file from the External job through the QMC. Let Me know if anyone needed the solution i can provide the steps.

Regards

Balram

View solution in original post

6 Replies
dilipranjith
Partner
Partner

Post reload triggers doesnt work on QV server environment by design

see Macro trigger limitations section in below link

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/UsingMacrosonQV...

balrammahato204
Creator
Creator
Author

Hi Dilip,

Is there any way to execute the Macro. I have tried with batch file using below code, But still not able to achieve. Please let me know if any another way is available to achieve this.

"c:\Program Files\QlikView\QV.exe" /r "G:\Qlikview\Test.qvw">> G:\Qlikview\Test.log

 

Regards

Balram

martinpohl
Partner
Partner

Nope, no possibilities.

There are two workarounds:

- Use NPrinting to send values to Excel and user.

- Create the table in your script and store them into a .csv-file and open it with excel.

Regards

balrammahato204
Creator
Creator
Author

Thanks for Response.

I have Achieved the solution using Powershell and  html codes. Also post reload trigger is working once i am triggering the file from the External job through the QMC. Let Me know if anyone needed the solution i can provide the steps.

Regards

Balram

View solution in original post

dhasharadh
Creator III
Creator III

Hi Balrammahato, 

we are also facing the similar issue, we have to trigger a macro on post reload, but on postreload option is not working for us, that too we are not running it in QMC, in the manual run it self it is not working. 

please guide us what have you done and how on post reload option worked for you...

Thanks in advance.

BR,

Dhasharadh

balrammahato204
Creator
Creator
Author

Hi,

Please find the steps below

First Set up this process for Export Image and Create your email body and set up to call the power shell file from Qlikview. In this URL all setting are available. Below yellow highlighted steps I have added verify the steps and let me know where you have the issue.

https://community.qlik.com/t5/QlikView-Documents/Sending-email-from-Qlikview/ta-p/1486016

  1. Script Powershell: (Save this script on email.ps1)

$att = new-object Net.Mail.Attachment("C:\temp\imagem.jpg")

$att.ContentId = "att"

$smtpServer = "smtp.gmail.com"

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$body = 'Image and text<br /><img src="cid:att" />'

$msg = new-object Net.Mail.MailMessage

$msg.From ="name@domain.com.br"

$msg.To.Add("name@domain.com")

$msg.Subject = 'Text, Image and CC from powershell'

$msg.Body = $body

$msg.IsBodyHTML = $true

$msg.Attachments.Add($att)

$smtp.Send($msg)

$att.Dispose()

 

Well, we really can improve this script checking if there is an image on path, or even using credentials to turn this script safer. But 'now()', this is enough. 

 

 

  1. Macro to save images:

public function ExportImage

  ActiveDocument.GetApplication.WaitForIdle

  ActiveDocument.GetSheetByID("DASH").Activate

  vFolder = ActiveDocument.GetVariable("c:\temp\").GetContent().String

  set obj = ActiveDocument.GetSheetObject("EXPORT")

  ActiveDocument.GetApplication.WaitForIdle

  fileName = "imagem.jpg"

  ActiveDocument.GetApplication.WaitForIdle

  obj.ExportBitmapToFile vFolder & fileName

end function

 

 

  1. To send message:

Create a button and assign two triggers:

3.1 Run a macro to save images

3.2 Set an event 'Set' that will run Powershell script.

 

 

2) Make sure you have used these two Macro while saving the images.

ActiveDocument.Save
Application.Quit

3) Make sure You have the below setting Enable on while writing Macro

Requested Mode Security - >System Access

Current Local Security -->Allow System Access

4)Check the security Settings on Document Properties-->Macro Override Security is on

5) Check the Security Setting on User Preference -->confirm Launch from Macro is On

6) Make sure While reload complete of QVW file option is enable -->Close when finished

7)Create the external batch to call the QVW file from QMC using below commands

"c:\Program Files\QlikView\QV.exe" /l "Path\Test.qvw"