63
Views
8
Comments
Solved
[JSON Pretty Format Reactive] JSON Pretty Print only working sometimes on the first time page is loaded
json-pretty-format-reactive
Reactive icon
Forge asset by Pedro Domingues
Application Type
Reactive
Service Studio Version
11.54.13 (Build 62526)

Have installed the JSON Pretty Format Reactive component and trying to use it in my reactive app. It doesn't seem to work at all, I have noticed on a couple of occassions that after I have published the UI module that the first time I refresh my app that the pretty format works, and I can see the formatted JSON there - however refreshing the page again, or trying to navigate back to that page it no longer works. Have tried logging out and back in, but it wont ever show up again. 

I have console logged through the JSON_PrettyFormat action in the component and can see that the inputs I'm providing are there successfully.

The element is empty when I inspect it. 


My screen has an aggregate which gets a number of records from the database, and one of the attributes is a text string which I want to display as pretty formatted JSON.

Some example JSON that I'm using

{"access_type":"login","client_id":"abcd1234"} 


Is there something additional I need to do to get this component to work? 


Thanks

2019-05-07 15-30-20
Pedro Miguel de Andrade Rodrigues
Solution

Hi John,

I’m sorry to hear that the component does not seem to be working as expected. Could you upload in here a module where the problem is visible? I’ll try to take a look at it in the coming days.

Greetings, Pedro

UserImage.jpg
John Ronis

Hi Pedro, 


Thanks for getting back to me, 

When I tried to reproduce it in another module I didn't have any problems. After a fair amount of testing found it was due to a different block on the same screen, that I dont think is related at all (a userInfo block in the layout header), was somehow interfering with it. 

I have made a minor change to that other block and everything appears to be working fine now. 

Thanks

2019-05-07 15-30-20
Pedro Miguel de Andrade Rodrigues

Hi John, I’m glad to hear you managed to solve the issue.

Greetings, Pedro

2022-02-09 17-18-50
Rafaela Azinhal

Hi.

Can you pease share what did you change on the other block?

I seem to have a similar problem: a page with two JSONPrettyFormat blocks, one displays correctly and the other doesn't, although debugging shows the underlying variables to be correct JSon texts.

Thx.

2026-03-23 09-58-51
Pedro Domingues
Champion

Hi Rafaela, how are you?

Can you please share the OML file were you're facing the issue?

Cheers,

Pedro Domingues

2022-02-09 17-18-50
Rafaela Azinhal

Hi, Pedro.

I've pinpointed the problem to be somehow related to an assignment to a "client" variable in the same flow where the object is serialized and assigned to the local variable attached to the JSONPrettyFormat block.

Please find attached the OML which demonstrates the reported behaviour.

JsonPrettyFormatBug.oml
2026-03-23 09-58-51
Pedro Domingues
Champion

Hi Rafaela, how are you?

Sorry for the delay. I found the reason why the JSON is not being prettified and it's not related with the component itself but with the how the platform deals with Client variables.

Client variables doesn't trigger the "OnChange" input parameters event. You can check it by yourself on a sandbox. I faced this also in the past and that's why it immediately came to my head that this was the issue. That explains why it works with a local variable and not with a Client variable.

To prove my theory i copied the JS from the component (the one that renders the JSON Prettify) and pasted it on the client action FormatObjectToJson_OnClick from your module. It instantly worked as expected (check the attached image).

My suggestion is for you to review the way you assign the JSON to the Block. Unfortunately there's not much we can do here.

Cheers,

Pedro Domingues

FormatObjectToJson_OnClick.png
2022-02-09 17-18-50
Rafaela Azinhal

Hi, Pedro.

Thank you so much for your analysis! 

Yes, I already had worked around that behaviour, using a local variable, but I was wondering why, and your explanation clarified it :-)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.