org-scn-design-studio-community / lumiradesignercommunityext

Lumira Designer SCN Community Extensions
Apache License 2.0
3 stars 2 forks source link

Replacer script issue in 2.0 #15

Closed dagw0od closed 6 years ago

dagw0od commented 6 years ago

Hi

Replacer worked wonders for us in 1.x.

In 2.0 we receive a script error when running the application. This is the method called in "On Startup" that works in 1.6 but produces an error in 2.0 SP02 Patch 1:

REPLACER_1.replaceAccordingToMapping();

Thanks for all the amazing work!

entmike commented 6 years ago

Hey dagw0od,

I can probably push a fix up for this next week. Sorry for delay.

dagw0od commented 6 years ago

Thanks Mike

We are ready to test as soon as you have it available.

Also planning to get involved, but we may take a while to get going.

MartinPankraz commented 6 years ago

Hi dagw0od,

Thanks for reaching out. Some changes to the SAP SDK framework crashed the components api methods. The next release of our repository will fix the problem.

Kind regards Martin

MartinPankraz commented 6 years ago

Hi dagw0od,

build done. You can update now. Please let us know if your issue is fixed.

Kind regards Martin

dagw0od commented 6 years ago

Thanks Martin. It is working now (Lumira 2.1 BI Plat 4.2 SP5). Do you have some documentation available on using regular expressions in Replacer? I have tried a few variants but none of them seem to work. The only documentation I could find so far is your blog post from June 2016

MartinPankraz commented 6 years ago

Great, that is good to hear. I never documented anything regarding regular expressions because you can use all variations understood by javascript. In addition to that it is a very disruptive component which might cause problems with unintended side effects for unexperienced users. Maybe you can show me your selector and what you are trying to select? Most probably there is a syntactical problem. I've been playing with very complex expressions before.

dagw0od commented 6 years ago

We're only playing around now to see what's possible, now that it's working on 2.1. It is probably a syntactical issue.

I have header text "Dec 2017". I want to replace the "2017" with test so my end result should be "Dec TEST".

By using the correct CSS to reference the header, Match "2017" and Replace "TEST" I get the whole header replaced with "TEST".

So Replacer is working, but I still need to get my partial replacement.

I am struggling with the regex to only replace part of the header. I have tried a few examples from stackoverflow and w3schools.

Thanks for any advice you can pass on to us.

MartinPankraz commented 6 years ago

I see. Are you using a crosstab? Could you paste a screenshot of the relevant part of the html dom tree? Another line of thought would be to reference parts of texts using the :contains or :text selector.

Kind regards Martin

dagw0od commented 6 years ago

Yes, we are using a crosstab (CROSSTAB_R) and Replacer references that crosstab.

This is the header:

image

And the dom tree:

image

And the line from Replacer that changes the whole header to "TEST" if it finds "2017":

image

I will try those references tomorrow, thank you.

MartinPankraz commented 6 years ago

Thanks for the info. Actually my hint from yesterday will not help you with your problem. The selectors I mentioned are meant to create more selective queries.

I just checked the code. I never anticipated replacing parts of a text on a html dom tree leaf. That would involve additional effort. Do you have a specific demand for that?

dagw0od commented 6 years ago

We are trying to overcome another shortcoming of the BI Platform - customising number formatting. (Replacer works great for something else, but we thought it might work for this too).

Basically, all BI Platform tools pick up the number formatting from the browser locale. Our locale is English and number formats are always #,###.00. (Dates can be an issue too, but these are not usually in a chart/crosstab and can be manipulated).

Our business requires a specific number format # ###.00 (so basically the thousand separator is a space). In Webi this was overcome with string formatting on measures. In Lumia Designer this is not possible without some SDK work. In Lumira Discovery I'm not sure if it will be possible at all.

We have a call open with SAP.

Some locales give the correct format, but raise further issues with language on the platform.

MartinPankraz commented 6 years ago

Ok I see. It is intentionally hard to mess with this probably due to standard sap settings. I will see if I can enhance the replacement function to targte parts of texts as well soon.

MartinPankraz commented 6 years ago

I just made an update. Could you please test your first use case and the new one? I'd like to make sure both still work as before with the more powerful replacement function.

Kind regards Martin

dagw0od commented 6 years ago

Hi Martin

Thanks for the update I still get the same result with the full replacement. Is there certain syntax I should use to replace a certain part?

Best Doug

MartinPankraz commented 6 years ago

Hi Doug,

No you should be good with a selector like in your example. Just add a matching and a replacing text. For example for Jan 2017 you can put "Jan" as matching and Test as replacement. That results in "Test 2017" on my end. Please make sure the update went through correctly by comparing time stamps. I updated today at around noon.

Kind regards Martin

dagw0od commented 6 years ago

Hi Martin

I downloaded your update from today, the timestamp looks right:

image

Here is my crosstab header and the Replacer mapping table (I created a brand new application, just for testing).

image

Here is the output. It is replacing the whole item when there is a match.

image

Best Doug

MartinPankraz commented 6 years ago

Your example is looking good. I mixed up the indexes. Please try again. I updated just now.

Kind regards Martin

dagw0od commented 6 years ago

Amazing. Thanks Martin!

Both cases work.

Case 1: I'm just number formatting and changing the thousand separator from a comma to a space.

Case 2: if a variance is greater than or less than a certain threshold it gets replaced with an indicator to show that the variance is very large. (so a variance of 4000% might be shown as just >1000) - this always worked in Replacer.

Thank you so much

Best Doug

sudharsan1304 commented 5 years ago

Hi, I have the build for Lumira Designer. I couldn't find the component "Replacer" under utilities. Could you please help me with that.

Regards, Sudharsan G