System Event - SuccessfulLogin

I'm trying to run this method on the System Event Successful Login but get an error "Not a single item" The SQL is bring back 1 record since I'm using the "Select top(1)". I'm not sure why the error.

Innovator inn=this.getInnovator();
String SQL = "Select top (1) aras_session_id as nb from [Test500].[application].[ACTIVEUSER] where login_name = 'hdportal' order by login_time desc";

    SQL = String.Format(SQL,this.getProperty("id","error"));
    Item res = this.getInnovator().applySQL(SQL);
    if (!res.isError())
    {
        string nb = res.getProperty("nb","");

        Item cSession = this.newItem("MIN_PORTAL_STORE_ID","edit");
        cSession.setID("26E9C01A4C264B80967D07F2F386BD1B");
        cSession.setProperty("session_id",nb);        
        cSession.apply();
    }
return this;

Parents
  • Error is coming in the below mentioned line

    Innovator inn=this.getInnovator();
    String SQL = "Select top (1) aras_session_id as nb from [Test500].[application].[ACTIVEUSER] where login_name = 'hdportal' order by login_time desc";

        SQL = String.Format(SQL,this.getProperty("id","error"));
        Item res = this.getInnovator().applySQL(SQL);
        if (!res.isError())
        {
            string nb = res.getProperty("nb","");

            Item cSession = this.newItem("MIN_PORTAL_STORE_ID","edit");
            cSession.setID("26E9C01A4C264B80967D07F2F386BD1B");
            cSession.setProperty("session_id",nb);        
            cSession.apply();
        }
    return this;

    What is significance of this line. If you remove this line, you code should work.

    Thanks,

    Gobikrishnan

  • I removed the line, but still doesn't work. Anything else I can try?

  • Innovator inn=this.getInnovator();
    String SQL = "Select top (1) aras_session_id as nb from [application].[ACTIVEUSER] where login_name = 'hdportal' order by login_time desc";
        Item res = this.getInnovator().applySQL(SQL);
        if (!res.isError())
        {
            string nb = res.getProperty("nb","");

            Item cSession = this.newItem("MIN_PORTAL_STORE_ID","edit");
            cSession.setID("26E9C01A4C264B80967D07F2F386BD1B");
            cSession.setProperty("session_id",nb);        
            cSession.apply();
        }
    return this;

    This code I used

Reply
  • Innovator inn=this.getInnovator();
    String SQL = "Select top (1) aras_session_id as nb from [application].[ACTIVEUSER] where login_name = 'hdportal' order by login_time desc";
        Item res = this.getInnovator().applySQL(SQL);
        if (!res.isError())
        {
            string nb = res.getProperty("nb","");

            Item cSession = this.newItem("MIN_PORTAL_STORE_ID","edit");
            cSession.setID("26E9C01A4C264B80967D07F2F386BD1B");
            cSession.setProperty("session_id",nb);        
            cSession.apply();
        }
    return this;

    This code I used

Children
No Data