how to test existing of a custom type in a server with EKL?

ibrahim yucedag

how to test existing of a custom type in a server with EKL?

I am trying to write a code but due to a custom type not being exist on the server I keep getting attached error. I am writing code for customer hence all types does not exist in my environment. Part of the code is below;

else if MyResourceRef.IsSupporting("EkipmanKalip")==True
{
   lengt = LinkedOpRef.V_description.Length()
   indx = LinkedOpRef.V_description.Search("/")
   LinkedOpDesc = LinkedOpRef.V_description.Extract((indx+1),(lengt-indx-1))
   MyResourceRef.V_description= "Ekipman Kalıp" +" /"+ LinkedOpDesc
}

error I am getting is "...(EkipmanKalip) is not an existing type"

 

Attachments

  • error.jpg (8.1k)
Edited By:
ibrahim yucedag[Subscriber Members] @ May 26, 2022 - 09:14 AM (Europe/Istanbul)
ibrahim yucedag[Subscriber Members] @ May 26, 2022 - 09:15 AM (Europe/Istanbul)

Matt Hanson

RE: how to test existing of a custom type in a server with EKL?
(in response to ibrahim yucedag)

I would first write a test code that returns the object types that are actually available.  Create a blank model, insert the known part type, and then return all objects in the model.  Then, and only then, proceed to writing code that uses the ".IsSupporting" statement.

 

I understand that the type may not exist in your environment.  You may need to get the customer to send you a model with the object type present.  Or you may need to define it, yourself.

 

If that isn't an option, write your code first against a known type, and once it's working on whatever that type is, replace all references to the test object, with the custom type. 

Edited By:
Matt Hanson[Rivian] @ May 26, 2022 - 09:37 AM (America/Eastern)
Matt Hanson[Rivian] @ May 26, 2022 - 09:40 AM (America/Eastern)

Mahefa Ralijaona

RE: how to test existing of a custom type in a server with EKL?
(in response to ibrahim yucedag)

Hello,

You can use the FindType function, as follows:

let LegoType (Type)
LegoType = FindType( "LEGO_Part_CEXT" )

if LegoType <> NULL
{
    Notify( "LEGO_Part_CEXT is an existing type" )
}
else
{
    Notify( "LEGO_Part_CEXT is an unknown type" )
}

let NonExistingType (Type)
NonExistingType = FindType( "NonExistingType" )

if NonExistingType <> NULL
{
    Notify( "NonExistingType is an existing type" )
}
else
{
    Notify( "NonExistingType is an unknown type" )
}

The result is in the picture attached.

Attachments

  • FindType.jpg (11.3k)

ibrahim yucedag

RE: how to test existing of a custom type in a server with EKL?
(in response to Mahefa Ralijaona)

this is perfect. with this I can first test the type existence then do the trick. Thank you very much. 

ibrahim yucedag

RE: how to test existing of a custom type in a server with EKL?
(in response to ibrahim yucedag)

I failed again. What I have at this pointis;

 

if FarplasBoyahane<>NULL and FarplasEnjeksiyon<>NULL and FarplasMontaj<>NULL and FarplasKaucuk<>NULL and FarplasAltlik<>NULL and FarplasAparat<>NULL and FarplasKalip<>NULL and FarplasMetalKalip<>NULL and FarplasRobotAltlik<>NULL and FarplasYardimci<>NULL and FarplasEkipman<>NULL
{
if MyResourceRef.IsASortOf("ResourceBoyahane")==True
{
lengt = LinkedOpRef.V_description.Length()
indx = LinkedOpRef.V_description.Search("/")
LinkedOpDesc = LinkedOpRef.V_description.Extract((indx+1),(lengt-indx-1))
MyResourceRef.V_description= "Boyahane" +" /"+ LinkedOpDesc
}
else if MyResourceRef.IsASortOf("ResourceEnjeksiyon")==True
{
lengt = LinkedOpRef.V_description.Length()
indx = LinkedOpRef.V_description.Search("/")
LinkedOpDesc = LinkedOpRef.V_description.Extract((indx+1),(lengt-indx-1))
MyResourceRef.V_description= "Enjeksiyon Alani" +" /"+ LinkedOpDesc
}
*
*
*
*
*
else if MyResourceRef.IsASortOf("EkipmanKalip")==True
{
lengt = LinkedOpRef.V_description.Length()
indx = LinkedOpRef.V_description.Search("/")
LinkedOpDesc = LinkedOpRef.V_description.Extract((indx+1),(lengt-indx-1))
MyResourceRef.V_description= "Ekipman Kalıp" +" /"+ LinkedOpDesc
}
}
else
{
Notify( "Type does not exist" )
}

still getting ".....not an existing type error." hence cannot pass the action to customer.

Matt Hanson

RE: how to test existing of a custom type in a server with EKL?
(in response to ibrahim yucedag)

If you're getting a "not existing type" error, then the type doesn't exist.  As stated before, you either need to define the type in your configuration, OR you need to test everything against an existing type, and then replace the type reference before you ship the code to the customer - in whose instance the type DOES exist.

Just build your code around the nearest object type, to the one that the custom type was built from.  i.e., if it's built from a VPMReference, write your code around that, and then replace all references to the object after proof.  Of course, it's also on you to define all of the custom attributes and properties that exist in the custom type.

Just curious how you managed to get a task for a custom deployment, with no access to the database that it's defined from?

Mahefa Ralijaona

RE: how to test existing of a custom type in a server with EKL?
(in response to ibrahim yucedag)

As soon as you explicitly provide to IsASortOf method, a string representing the name of a type that doesn't exist on your platform, you will get this error message.

Using the FindType function is a way for you to do this check (existence of a given type on the platform) prior to working with objects of that type.

Now let's mix Matt's suggestion with mine: the customer has created a type named "LEGO_Part_CEXT" that derives from VPMReference. This type defines the following attributes:

  • LegoPartID (String)
  • LegoPartFamily (String)
  • LegoPartColor (String)

I'm writing an action that first checks whether that type LEGO_Part_CEXT exist on the platform. If yes, I use a variable of type VPMReference. I evaluate it somehow and then if during runtime that variable happens to hold an object of the LEGO_Part_CEXT, I write the corresponding attributes above.

If the LEGO_Part_CEXT is not defined on the platform, I simply abort the process after telling the user the type is not existing on the platform.

---------------------------------------------------------------------------------------------------------------------------------------


// Test whether LEGO_Part_CEXT type does exist on the platform, if not, abort the process. Continue otherwise.
let LegoTypeAsString (String)
LegoTypeAsString = "LEGO_Part_CEXT"

let LegoType (Type)
LegoType = FindType( LegoTypeAsString )

// If LEGO_Part_CEXT is not existing on the platform, warn the user and abort
if LegoType == NULL
{
    PopupMessage( "The LEGO_Part_CEXT type is not an existing type. Please contact your Administrator." )
    exit
}

// From this point, LEGO_Part_CEXT is an existing type on the platform, but do not refer to it explicitly,
// use the variable LegoTypeAsString containing the name of the type.
let MyResourceDef (VPMReference)
// Assumption is made that the type LEGO_Part_CEXT derives from VPMReference

/*
some code that evaluates MyResourceDef ...
MyResourceDef = ...
...
*/
if MyResourceDef.IsASortOf( LegoTypeAsString )
{
    // Use SetAttributeXXX (XXX = String, Integer, Boolean etc) because these methods are generic
    MyResourceDef.SetAttributeString( "LegoPartID", "12345" )
    MyResourceDef.SetAttributeString( "LegoPartFamily", "Plate" )
    MyResourceDef.SetAttributeString( "LegoPartColor", "Blue" )
}

Hope it helps.

ibrahim yucedag

RE: how to test existing of a custom type in a server with EKL?
(in response to Mahefa Ralijaona)

Hello Mahefa, thank you very much for your valuable comment. Apparently we managed to go around the type check of EKL thank to not using custo types explicitly. 

I have this now;

 

if typeFarplasBoyahane==NULL or typeFarplasEnjeksiyon==NULL or typeFarplasMontaj==NULL or typeFarplasKaucuk==NULL or typeFarplasAltlik==NULL or typeFarplasAparat==NULL or typeFarplasKalip==NULL or typeFarplasMetalKalip==NULL or typeFarplasRobotAltlik==NULL or typeFarplasYardimci==NULL or typeFarplasEkipman==NULL
{
PopupMessage( "Type is not an existing type. Please contact your Administrator." )
exit
}
else
{

ibrahim yucedag

RE: how to test existing of a custom type in a server with EKL?
(in response to Matt Hanson)

Hello Matt,

when I first created the Action customer was on a evaluation license and it expired. Now they wanted to have some more subtypes added to it hence I have to expand the code. 

I wanted to create those custo types in my VM however I could not get these created in the server even though Data Model Customization app says they are deployed. Please check the attached photo. 

Attachments

  • custo resource extensions.jpg (40.6k)