cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create a composite key in BO.

Former Member
0 Kudos

Hello Experts,

Can we create composite key declaration Inside the BO definition ?

I tired by declaring

[AlternativeKey] [Label("Attribute ID")] element AttributeID:ID;

[AlternativeKey] [Label("Attribute Value")] element AttributeValue:LANGUAGEINDEPENDENT_LONG_Text;

But while maintaining the data if am trying to maintain the data it considering only the attribute as key .

My requirement is to consider Attribute ID and Attribute Value as Composite key.

Regards,

Papps

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Papps,

As per my understanding, you want to consider the 2 fiels as the alternative key?

if it is, i think you can try create 3 fields in your BO, 2 of them are Attr ID, Attr Value(do not use AK annotation), and with the 3rd one, for  example "combinedAK" to be defined as AK element.

and in your script : conbimedAK = AttrID + AttrValue;

And this result will be considered as AK value.

Regards,

Qiang

Former Member
0 Kudos

Hello Qiang,

Thanks for your reply,

If I understood correctly in the BO I will have those 2 elements but not declaring it as Key , the third element which will be concatenate value of the first two. That I can define as a Key.  and in the script I will concatenate the two elements to the third one which is key.

So which Script should I use for doing this ? is it ONLOAD or AFTERMODIFY

would you please provide some more information for this ?

Regrads,

Papps

Former Member
0 Kudos

AfterLoading would be wrong.

If possible I would use BeforeSave.

If this for some reason does not meet your requirements you can also use AfterModify.

Best regards,

Ludger

Former Member
0 Kudos

AfterModify or BeforeSave, it based on your requirements.

Regards,

Qiang

Former Member
0 Kudos

Hi Qiang,

I am trying the solution as suggested by you.

Would you please provide the syntax for concatenating two values into the third one ?

Regards,

Papps

Former Member
0 Kudos

Hi Papps,

Yes, it is simple. You can try for example: this.AKextensionfield =  this.extensionfield1 + this.extensionfield2;

Regards,

Qiang

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Papps,

If you find a data type with 2 components which match your requirement you can use that one.

If you use the apporach from Qiang make sure that you can detect the delimiter so you can convert the key back and forth.

Bye,

    Horst

Former Member
0 Kudos

Hello Horst,

The approach provided by Qiang is working fine .

But by that approach the OVS has suffered and am getting error now on the OVS .

If you find a data type with 2 components which match your requirement you can use that one.


for this point would you please provide one example.


Regards,

Papps

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Papps,

I just played around and found the structure FormattedPostalAddress.

It has 3 elements

  • FirstLineDescription LANGUAGEINDEPENDENT_MEDIUM_Description
  • SecondLineDescription LANGUAGEINDEPENDENT_MEDIUM_Description
  • ThirdLineDescription LANGUAGEINDEPENDENT_MEDIUM_Description

I used this

     [AlternativeKey] element Key : FormattedPostalAddress;

to define the structured key.

It worked (Retrieve via AlternativeKey) for instances filled with only one element as well as with two or with all elements.

I didn't checked it via OVS.

Left this for you.

HTH,

   Horst

Answers (0)