Adding Clientside Code into Dynamically Built Workflow Action screens

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Adding Clientside Code into Dynamically Built Workflow Action screens

  • Comments 1
  • Likes

I had a conversation with a participant at one of the recent Bootcamps regarding the use of clientside code in dynamically built workflow screens.  This topic has also appeared in the Forums with the community site.

The partner's customer had a requirement that when a user was processing an opportunity one of the fields should be clearly marked in a different colour. 

 

In a static screen you could easily change the property of the field in HTML by using a script in the custom content box.  You would then change the style of the HTML tag.

This is discussed in the article "Using Custom Content Script to Change the Properties of a Field based on Displayed Value"

Within a Dynamically create Workflow screen there is no custom content.  Instead the script has to be added using the workflow action "Show Message on Screen".

 

The actual script has to be added as the "translation" for the message.

The fields are created in the dynamic screen wrapped in the same span tags that are used in a static window.

e.g.  

  • _captoppo_stage
  • _dataoppo_stage

The fields can then be referenced in the code.

<SCRIPT>
if (window.addEventListener)
{
//firefox way of binding an event
window.addEventListener("load", setStatusColor, false)
}
else 
if (window.attachEvent)
{
//IE exclusive method for binding an event
window.attachEvent("onload", setStatusColor)
}
function setStatusColor()
{
_Dataoppo_stage.style.color= "Red";
}
</SCRIPT>

 

Comments
  • Using the Caption Value of a field is also working very well. But you would lose the Caption of the field and Caption+"<script>..." is not working :-/. So you have to use CRM.GetTrans for the Field caption.