Jump to content
  • 0

Modify output text from formula in virtual field?


KG360

Question

Is there a way to modify the output text from a formula, for example making the text red or bold?

KG

PS: I often use HTML block to show warnings in red, but that required me to insert a new section and a few other virtual fields. Modifying the output text would be easier.

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
4 hours ago, GoodBoy said:

What formula and DataPage are you using? If it is a CASE WHEN statement in a report DataPage, then it is possible like in this post.

 

Many thanks @GoodBoy, this work for me in a virtual field with CASE WHEN statement and two conditions, in a form data page! I will test it some more tomorrow, but it looks good for now! This forum is invaluable../KG

Link to comment
Share on other sites

  • 0

Hi @KG360 - you may try this sample code if you would like to change the color of all Virtual Fields in the DataPage.
 

<script>
document.addEventListener('DataPageReady', function (event) {

    var elems = document.querySelectorAll("input[name*='cbParamVirtual']");
    elems.forEach((elem) => {
        elem.addEventListener('change', function () {
            if (elem.value === 'CORRECT') {
                elem.previousElementSibling.style.color = 'green';
            } else {
                elem.previousElementSibling.style.color = 'red';
            }
        });
    });
});
</script>

This will make the font color Green if the value of the Virtual Field is CORRECT and if not, it will be Red.

Link to comment
Share on other sites

  • 0
7 hours ago, Meekeee said:

Hi @KG360 - you may try this sample code if you would like to change the color of all Virtual Fields in the DataPage.
 

<script>
document.addEventListener('DataPageReady', function (event) {

    var elems = document.querySelectorAll("input[name*='cbParamVirtual']");
    elems.forEach((elem) => {
        elem.addEventListener('change', function () {
            if (elem.value === 'CORRECT') {
                elem.previousElementSibling.style.color = 'green';
            } else {
                elem.previousElementSibling.style.color = 'red';
            }
        });
    });
});
</script>

This will make the font color Green if the value of the Virtual Field is CORRECT and if not, it will be Red.

Many thanks @Meekeeethat looks like a very elegant solution, will try it out. Several of the virtual fields are hidden but changing their color should not affect their role in formulas I suppose. Will let you know how it goes once I have tried it out.

/KG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...