Forum Discussion

ddidonato's avatar
ddidonato
Creator II
3 years ago

idlist

Can I use idlist in a server-side VB. I have a SQL string that returns a bunch of part id's. I would like to use it on beforeget on the itemtype PART

3 Replies

  • OnBeforeGet Methods are mainly used for search filter tasks. You typically use the Method to overwrite search conditions. Not sure if you can use idlist, but I would try this:

    this.setAttribute("idlist", ...);

    return this;

    • ddidonato's avatar
      ddidonato
      Creator II

      This is what I have now. Comes back as "Not a Single Item". Any Suggestions?

      Dim tmpInn As Innovator = Me.getInnovator()
      Dim dd_parm0 As String = tmpInn.getUserID()

      if dd_parm0 = ("C87129C35EBE4AD7AF9F8C012DDE8C5B") Then
      Dim i As Integer
      Dim xx As String = CStr(CCO.Session("arasSESSID"))

      For i=0 To me.getItemCount()-1
      Dim currentW As Item = me.getItemByIndex(i)
      Dim SQL As String = "SELECT DISTINCT ........ = " +  "'" + xx + "')"

      SQL = String.Format(SQL, xx)
      Dim res As Item = currentW.getInnovator().applySQL(SQL)
      If Not res.isError Then
      Dim nb As String = res.getProperty("nb", "")
      currentW.setAttribute("idlist", nb)
      End If
      Next i
      Return me
      End If

      • angela's avatar
        angela
        Catalyst II

        You "get not a single item" error message cause there is no single item.

        Use a newError message to let yourself display the content of me/this. You will notice that "me" contains the search query, not the query result. That´s the reason I mentioned that onBeforeGet is mostly used for search filters. So you cannot loop through the items, cause you only have one (the search query itself).

        What is your use case? The current concept looks like the beginning of a performance disaster waiting to happen [emoticon:0f36700dfeb3494fa10d47dd9e1f90a1]

        It can lead to problems if you applySQL/AML calls in a loop. If using "idlist" in a loop like this, it will probably only overwrite the idlist over and over again. Try to design your SQL query in a way, that it already will return the final comma separated idlist that you than can use like this:

        me.setAttribute("idlist","id1,id2,id3,...");
        return this;

        And this one
             Dim res As Item = currentW.getInnovator().applySQL(SQL)
        should better be
             Dim res As Item = tmpInn.applySQL(SQL)

        Good luck :)