Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

call macro from load script

Hi,

I'm trying to call this macro to create alerts from the load script:

Function alertCreate ()
rem create new alert with mail
dim docprop, al, no, no2
set docprop = ActiveDocument.GetProperties
set al = docprop.Alerts
al.Add
no = al.Count-1
al.Item(no).Action.Id = "AL04"
al.Item(no).Action.SuppressPopup = true
al.Item(no).Action.Message.v = "Hello world!"
al.Item(no).Action.MailRecipients.Add
no2 = al.Item(no).Action.MailRecipients.Count-1
al.Item(no).Action.MailRecipients.Item(no2).v = "santa.claus@northpole.gov"
al.Item(no).Action.MailSubject.v = "Alert: Hello world!"
al.Item(no).Comment = "New alert"
al.Item(no).Condition.AllClear = false
al.Item(no).Condition.BookmarkId = "BM01"
al.Item(no).Condition.Condition.v = "sum(Sales)>Sum(Budget)"
al.Item(no).Enabled = true
al.Item(no).Triggers.Interactive = true
al.Item(no).Triggers.OnPostReload = true
ActiveDocument.SetProperties docprop
end Function

And then I want to call it from the load script like:

LET b = alertCreate();

The alert is not created after doing a reload. I cannot use the OnPostReload event because I want to use the publisher. My question is, if I finally make this macro work (using the call from the script), later, when running the reload from the publisher, is it going to execute the macro call when the script arrives to this line? Or it will happen the same as when using OnPostReload event?

In oder words, the publisher will not execute any kind of macro in any part of the document: in the load script, in the document events using the trigger<external<run macro...

Was it understandable?

Thanks

2 Replies
Stefan_Walther
Employee
Employee

Hi,

you cannot call this type of macro from within your load script because ActiveDocument is not available while the load-script is running.

Regards
Stefan

dhborchardt
Partner - Creator
Partner - Creator

I am able to call the macro and send the email but I just can't pass the variable. Is there another way besides ActiveDocument to get the variable passed?

Is there another kind of macro I should be using?