Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
Absent Member.. SWhild Absent Member..
Absent Member..
848 views

TRIM SDK - Typed Title Length Exception

Hello,

 

I am trying to import some records into TRIM 7.33 using the TRIM .NET SDK and the Bulk Loader.

I am setting the typed title of each new record using 

nr.TypedTitle = rec.TypedTitle;

where nr is the new record and rec is the information exported from an old TRIM SQL Server database.

 

Unforunatly I am getting a TRIM Exception when running the code stating that:

{"Property 'Title (Free Text Part)' is limited to 254 characters of text.  Please supply a shorter string value."}.

When I watch rec and check the TypedTitle length property is states that the length is 253 characters.

 

I have looked into the character sets and c# is UTF-16 and SQL Server is UCS2. From what I understand they are compatible as they both use 2 Bytes for each character.

Any suggestion for what to check next?

Tags (3)
0 Likes
4 Replies
Richard Kelly_7 Absent Member.
Absent Member.

Re: TRIM SDK - Typed Title Length Exception

Does UTF-16 not have a Byte Order Mark (BOM) at the start of the string - which I think is 2 characters?   Try dropping your string length by 2 and see if that dies it.   Another alternative is UTF-8 which will inevitably be shorter as all ASCII characters are represented by a single byte.

Note: Any posts I make on this forum are my own personal opinion and do not constitute a formal commitment on behalf of Hewlett Packard Enterprise.
0 Likes
Absent Member.. SWhild Absent Member..
Absent Member..

Re: TRIM SDK - Typed Title Length Exception

Hi Richard,

 

I didnt think the BOM would be affecting it as c# usually drops that when you add a string to a SQLParameter.

I have changed the string to a CharArray before assigning it to the variable and it is still not working.

I did have to change the assign method to what I have below:

nr.SetProperty(PropertyIds.RecordTypedTitle, rec.TypedTitle.ToCharArray());

After that I have modified it to:

nr.SetProperty(PropertyIds.RecordTypedTitle, Encoding.UTF8.GetBytes(rec.TypedTitle));

 I am now getting nothing set for the title once the import is complete.

I dont want to trim the string as that would cause me to lose data that is coming from the old system.

0 Likes
Richard Kelly_7 Absent Member.
Absent Member.

Re: TRIM SDK - Typed Title Length Exception

I think I can understand why a char array will not work, but I would still be tempted to try and shorten the string one char at a time to see what it will go with.  You can then see on those records that exceed the limit what the last few and first few chars are - and for that matter identify how many records will be affected.   The other thing you could try doing is setting the TypedTitle directly rather than via SetProperty.

Note: Any posts I make on this forum are my own personal opinion and do not constitute a formal commitment on behalf of Hewlett Packard Enterprise.
0 Likes
Absent Member.. SWhild Absent Member..
Absent Member..

Re: TRIM SDK - Typed Title Length Exception

Hi Richard,

 

I have attempted to shorten it and it turns out I have to shorten the String by 2 characters for it to accept it. Unfortunately as we are importing a lot of data there are a fair few records this would affect.

I have done something a bit unusual but I have done some big Imports without issue. That is, I cast the String to a Char Array and then created a new String out of that and assigned it to the Title using SetProperty.

nr.SetProperty(PropertyIds.RecordTypedTitle, new String(rec.TypedTitle.ToCharArray()));

 For some reason this works. I don't understand how the TRIM SDK is testing the size but this seems to get around it.

 

Regards,

Steven

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.