Skip to main content
Nintex Community Menu Bar
Question

javascript: add string into another string at a specific location?

  • July 9, 2024
  • 8 replies
  • 19 views

Forum|alt.badge.img+18

Ok, experts–

I have two rich text fields in different objects. We’ll call one is InteractionNote__c on the Interactions object, and the other CaseNotes__c, on the Case object. Interaction is a child of Case.

CaseNotes__c is a bulleted list of all of the InteractionNote__c fields from all of the Interactions in the Case.

Say that currently Case has three interactions, and CaseNotes__c looks like this:

<ul>
<li>Note 1</li>
<li>Note 2</li>
<li>Note 3</li>
</ul>

I need to write a script that will take the value of InteractionNote__c when a new interaction is saved (call it ‘New Note 4’), and dump it into CaseNotes__c so that the result is:

<ul>
<li>Note 1</li>
<li>Note 2</li>
<li>Note 3</li>
<li>New Note 4</li>
</ul>

I think I need some jQuery to find the last and add

'<li>' + InteractionNote__c + '</li> 

before it. Or find the last and add that after it?

Or some tricky javascript string functions?

This topic has been closed for replies.

8 replies

Forum|alt.badge.img+10

Interesting. Why do you want to store the notes twice? Could you instead use a template based on the Interaction model to render InteractionNote__c? Surround the merge field in a DIV and they’ll appear one per line rather elegantly. Or am I missing something?


Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

Nice idea, Glenn. I’ll look into it. In some situations I won’t have the Interactions model on the page, so I would have to add it. Although, I should probably use a page include since I have to replicate this across multiple pages.


Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

To clarify, a field editor on the Interactions model would accomplish the same thing, yes? But perhaps it wouldn’t look quite so nice.


Forum|alt.badge.img+17
  • Nintex Employee
  • 3766 replies
  • July 9, 2024

A field editor will accomplish the same thing.  It will repeat once per list item.  It can also be styled with custom styling - so you can get the look you want.  In both cases you will have to apply some custom CSS styling to get precisely the look you want. 


Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

Is there a way to skip blank fields in this scenario?


Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

Nevermind… simple model condition. 🙂


Forum|alt.badge.img+17
  • Nintex Employee
  • 3766 replies
  • July 9, 2024

Good to hear. 


Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

A follow-up, for anyone in the same boat:

The condition turned out not to be quite as simple as I expected: https://community.skuid.com/t/model-condition-rich-text-field-null-not-working