Where a smartobject is used

  • 30 September 2016
  • 7 replies
  • 26 views

Badge +6

Hi,

 

How it can be found out in which view / form a smartobject is used ?

 

I have a smartobject "XYZ". Need to find in which view / form it is used ?

 

Appreciate a quick response 

 

Thanks and Regards,

Satya


7 replies

Userlevel 5
Badge +18

One thing that you can do is use the package and deployment P&D tool to return dependencies.  Create a package and select only this SmartObject; this should return items that references this SmartObject.


 


https://help.k2.com/onlinehelp/k2blackpearl/PackageandDeployment/current/default.htm#Package_and_Deployment_System_Information.html

Badge +6

Hi tin,

 

Thanks for you reply. I was wondering if anything else apart from this exists.

 

Thanks and Regards,

Satya

Badge +2

Package and Deployment Tool does not list out the Forms and Views  where a partcular SmartObject is used.

It does the reverse where in it lists out the dependencies of a Form / View .

 

How can I find out in which Form(s) and View(s)  a Smartobject is used ?

 

Appreciate a response on this.

 

Thanks and Regards,

Satya

Userlevel 5
Badge +18

You can try using the following assemblies/apis:


 


using SourceCode.Forms.Management;
using SourceCode.SmartObjects.Client;
using SourceCode.Hosting.Client;


 


Found at "C:Program Files(x86)K2 blackpearlBin"


 


SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
connectionString.Authenticate = true;
connectionString.Host = "localhost";
connectionString.Integrated = true;
connectionString.IsPrimaryLogin = true;
connectionString.Port = 5555;

FormsManager fm = new FormsManager();
fm.CreateConnection();
fm.Connection.Open(connectionString.ToString());

SmartObjectClientServer smoserver = new SmartObjectClientServer();
smoserver.CreateConnection();
smoserver.Connection.Open(connectionString.ToString());

Console.WriteLine("Enter SmartObject SystemName (Not DisplayName):");
String smoSystemName = Console.ReadLine();

SmartObject smo = smoserver.GetSmartObject(smoSystemName);
Guid smoGuid = smo.Guid;
Console.WriteLine("SMO Guid: " + smoGuid);

//searches against Form XML for SmartObject Guid
Console.WriteLine("Found In: ");
FormExplorer fe2 = fm.GetForms();
foreach (FormInfo fi in fe2.Forms)
{
String formDisplayName = fi.DisplayName;
String formSystemName = fi.Name;
Guid formGuid = fi.Guid;
String formDef = fm.GetFormDefinition(formGuid);
if (fi.IsSystem == false && formDef != null)
{
if (formDef.Contains(smoGuid.ToString()))
{
Console.WriteLine("FormDisplayName: " + formDisplayName + " SystemName: " + formSystemName);
}
}
}

//searches against View XML for SmartObject Guid
ViewExplorer ve2 = fm.GetViews();
foreach (ViewInfo vi in ve2.Views)
{
String viewDisplayName = vi.DisplayName;
String viewSystemName = vi.Name;
Guid viewGuid = vi.Guid;
String viewDef = fm.GetViewDefinition(viewGuid);
if (vi.IsSystem == false && viewDef != null)
{
if (viewDef.Contains(smoGuid.ToString()))
{
Console.WriteLine("ViewDisplayName: " + viewDisplayName + " SystemName: " + viewSystemName);
}
}
}

fm.Connection.Close();
fm.Connection.Dispose();
smoserver.Connection.Close();
smoserver.Connection.Dispose();
Console.ReadLine();

Warning: not really a coder, but the applicable objects and methods are there


 


Enter SmartObject SystemName (Not DisplayName):
TestSMO_2
SMO Guid: f83e2308-2f87-4453-9896-1e5e8db13012
Found In:
FormDisplayName: FormNoIntegration SystemName: FormNoIntegration
ViewDisplayName: TestSMO Editable List SystemName: TestSMO Editable List
ViewDisplayName: NoIntegration SystemName: NoIntegration
ViewDisplayName: TestSMO Item SystemName: TestSMO Item

TestResult


 

Badge +12

You can use the query below to find which view/s smartobject XYZ is being used:

SELECT * FROM [K2].[Form].[View]
WHERE ID IN (SELECT ViewID FROM [K2].[Form].[ViewSource]
WHERE SourceDisplayName = 'XYZ')

Badge +4
This works and shows where the smartobject is being used in views/forms.
Badge +4
You could view the list by simply expanding the Smartobject from your Designer

Reply