Service Desk Practitioners Forum
cancel

Web API - Preventing Updates when Records "Already Open"

SOLVED
Go to solution
Highlighted
Marty Brown_1
Super Contributor.

Web API - Preventing Updates when Records "Already Open"

Hi all: An HPSD 4.5 SP21 User here...

I have written an integration using Java and the Web API that updates Change Records. It works great, but I would like to update my code so that it will Not proceed with updating a Change record if that record is currently Opened by a different user or process.

Said in a different way, what I'm trying to do is simulate the "This Item has already been opened by another User" capability that the HSPD Client has, but in Java / Web API code.

Does anybody know if there is a command in the Web API that would tell me if a record is already open for Write by somebody else???

Will give Points for any ideas!

Thanks!

~Marty
6 REPLIES
Vasily Kamenev
Acclaimed Contributor.

Re: Web API - Preventing Updates when Records "Already Open"

Hi
web-api does not containe this method.
idea is one - open hp source and look how it done in client.

Vasily
Alexander Kriku
Honored Contributor.

Re: Web API - Preventing Updates when Records "Already Open"

hi

the table ifc_entityusages stores the info about entities opened by users.

if the statement
select * from ifc_entityusages where eua_item =
returns rows, it means that someone has opened the Change
Marty Brown_1
Super Contributor.

Re: Web API - Preventing Updates when Records "Already Open"

Thanks guys! This gives me something to work with!

~Marty
Marty Brown_1
Super Contributor.

Re: Web API - Preventing Updates when Records "Already Open"

Does anybody out there have a Java code snippet that shows how I can access the HPSD Oracle Database Tables directly (not through the Web-API) and perform a SELECT statement and interrogate the results?

Any help will get Maximum points!

~Thanks!

~Marty
Alexander Kriku
Honored Contributor.
Solution

Re: Web API - Preventing Updates when Records "Already Open"

import java.sql.*;
import java.io.*;

public static void main(String[] argv)
{
try
{
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");

con=DriverManager.getConnection(
"jdbc:oracle:thin:@machine_name:1521:database_name",
"login",
"password");
Statement stmt=con.createStatement();

String sql = "select * from table";
ResultSet result = stmt.executeQuery(sql);
while(result.next())
{
String field01 = result.getString(1);//col number in result set
System.out.println("got: " + field01);
}

stmt.close();
con.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}


Marty Brown_1
Super Contributor.

Re: Web API - Preventing Updates when Records "Already Open"

Super!!! Thank you Alexander!

~Marty