cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using macro generating the SELECT used in HTML [Component=] tag

jff
New Contributor

Hi,

I build a macro who generate a particular SELECT ... where  [Date de modification] <  sysdate - 15 days

 

and I need to use this select in the [Component= ...] tag on an HTML description

thank's for your help

 

JFF

 

6 Replies

It can be done in different ways, but the best way for you would be to see some of the existing queries (that are based on macroes). If you execute the following query you get the queries. In the properties of each query you can see the macro, you see the classes etc.

 

Select [Query] Where [Collection Implementation]

 

 

How can a query be based on a VB script macro?
Which variable needs to be used to achive that?

jff
New Contributor

correction of the macro to include the context : mgobjObj.GetObjectPicture(Ctx)

'MegaContext(Fields,Types)
'Uses(WEBUtilities)
Option Explicit

' used to generate a HTML page
' strOut must return a valid HTML Page
Dim sValue
Dim Dt
Dim Dm
Dim Intit
Sub Generate (mgobjObj As MegaObject,Ctx As MegaWebSite,strIn As String,strOut As String)

  sValue = mgobjObj.GetProp("Date de modification")
  Dt=mid(sValue,9,2) & "/" & mid(sValue,6,2) & "/" & mid(sValue,1,4)
  Dm=CDate(Dt)
  if Dm >= date()-10 then
		Intit = mgobjObj.GetProp("Nom court","Display")
	  if strIn = "Diagramme" then
       if instr(mgobjObj.GetProp("Nom"),"(") > 0 then
			    Intit = mid(mgobjObj.GetProp("Nom"),1,instr(mgobjObj.GetProp("Nom"),"(") -1 )
       else 
          Intit = ""
       end if
		end if
    if Intit <> "" then
	    strOut=  "<TR><TD><img src=" & chr(34) & mgobjObj.GetObjectPicture(Ctx) & chr(34) & "/> <a  href=" & chr(34) & Lcase(mgobjObj.GetProp("_HexaIdAbs")) & ".htm" & chr(34) & " target=" & chr(34) & "_top" & chr(34) & ">&nbsp;" & Intit & "</a></TD> <TD>" & Dm & "</TD>" & "</TR>"
    end if
  end if
End Sub

jff
New Contributor

Hello,

to solve my problem , I made the following

Descripion :

\n		[Component="Select [Processus métier]" Sorter="Nom court:A"]
\n 		[ExternalCall Macro="Select_Object"]PM[/ExternalCall]
\n		[/Component]
\n    [Component="Select [Processus organisationnel]" Sorter="Nom court:A"]
\n 		[ExternalCall Macro="Select_Object"]PO[/ExternalCall]
\n    [/Component]
\n    [Component="Select [Opération]" Sorter="Nom court:A"]
\n 		[ExternalCall Macro="Select_Object"]Opération[/ExternalCall]
\n    [/Component]
\n    [Component="Select [Diagramme]" Sorter="Nom:A"]
\n 		[ExternalCall Macro="Select_Object"]Diagramme[/ExternalCall]
\n    [/Component]

Macro (Format HTML)

 

'MegaContext(Fields,Types)
'Uses(WEBUtilities)
Option Explicit

' used to generate a HTML page
' strOut must return a valid HTML Page
Dim sValue
Dim Dt
Dim Dm
Dim Intit
Sub Generate (mgobjObj As MegaObject,Ctx As MegaWebSite,strIn As String,strOut As String)

  sValue = mgobjObj.GetProp("Date de modification")
  Dt=mid(sValue,9,2) & "/" & mid(sValue,6,2) & "/" & mid(sValue,1,4)
  Dm=CDate(Dt)
  if Dm >= date()-15 then
		Intit = mgobjObj.GetProp("Nom court","Display")
	  if strIn = "Diagramme" then
       if instr(mgobjObj.GetProp("Nom"),"(") > 0 then
			    Intit = mid(mgobjObj.GetProp("Nom"),1,instr(mgobjObj.GetProp("Nom"),"(") -1 )
       else 
          Intit = ""
       end if
		end if
    if Intit <> "" then
	    strOut=  "<TR><TD><img src=" & chr(34) & mgobjObj.GetObjectPicture & chr(34) & "/> <a  href=" & chr(34) & Lcase(mgobjObj.GetProp("_HexaIdAbs")) & ".htm" & chr(34) & " target=" & chr(34) & "_top" & chr(34) & ">&nbsp;" & Intit & "</a></TD> <TD>" & Dm & "</TD>" & "</TR>"
    end if
  end if
End Sub

I don't know if this method is the GOOD method

 

jff
New Contributor

ok,

I have read this topic but my problem is to compute : (&CurentDate - 15 days) and put the résult as a date in the clause where of the SELECT. exemple : SELECT [Processus organisationnel] where [Date de modification] <=  &CurentDate -15

The macro who buil the select is :

Sub Generate(oObject, oContext, sUserData, sResult)
sValue = oObject.GetProp("Comment","Display")
sResult = "Select [Processus organisationnel] where [Date de modification] >=" & chr(34) & date()-15 & chr(34)
End Sub

 

thank you for your response

jhorber
MEGA
MEGA

Hello JFF

 

Certain system variables can be used in ERQL queries

See KB http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=50120000000mqO1AAI

 

Note also that a query can be based on a VB script macro. You can then use system variables of VB script language.

Jerome