Bug reports Found a bug? Post it here please.
Version 5.x > Bug reports > Import toolkit 5.5 data import substring macro not working View modes: 
User avatar
Member
Member
lancetek - 5/18/2011 3:07:37 AM
   
Import toolkit 5.5 data import substring macro not working
Substring macro's are not working for me. Here's the format I am trying to use:

"={%headline| (substring)0;20%}"


Problem: The data that is inserted in the database is not truncated properly.

Example: I have a 'headline' string of 80 chars.
Expected result: I expect the first 20 would go into the database when using the substring macro above.
Actual result: All 80 characters are inserted into the database.

Additional info: This incorrect functionality occurrs on any text field I try to substring.

Possible theory: Perhaps one of the macros 'breaks' the parsing engine or something, and the tool just quietly swallows the exception and stops parsing the macros? I dunno, since I don't have the source for the tool, this is just a wild theory.



Disclaimer: I've been having an offline conversation with Helena on email, and I thought I'd put it here to help others!


Hi Lance,


Thank you for your reply.

I was able to reproduce the issue. It occurs if the substring should be longer than the headline string is. You can test it with macros: ={%headline|(substring)0;10%} to see that it displays data correctly. We will inspect it and let you know.

Helena


Here's my reply:


Hi Helena,
The substring macro doesn't work for me: ={%headline|(substring)0;10%}

The substringing seems to be ignored and the full length of the fields are imported. Here's an example from a .iprofile


<mapping target="articlename" source="={%headline| (substring)0;20%}" />


Am I using it incorrectly?

Thanks,
Lance

User avatar
Member
Member
lancetek - 5/18/2011 3:54:28 AM
   
RE:Import toolkit 5.5 data import substring macro not working
I finally figured out what's wrong - my macro is in the wrong format!


Here's one that works:
={%headline|(substring)0;100%}

Here's one that doesn't work:
={%headline| (substring)0;100%}


Note the subtle extra space between the 'pipe' and the '(substring)'. This quietly breaks the macro.

Thanks to Helena for providing me the correct macro, and no thanks to me for typing it instead of copy 'n pasting it!

Please note that even though it was my fault for not understanding that macros are 'whitespace sensitive', I really would expect that an un-parseable macro would generate some sort of error in the tool to let me know that I'd gotten it wrong!

Thanks,
Lance