"HTML Script" on custom table

sumeet_n
Kilo Guru

Hello All,

I would like to have a field of type "HTML Script" - similar to what we have on Email templates table on a custom table. This will be dependent on another custom table so that I can use ${field_name} notation to substitute the values dynamically while sending emails. Emails? - I am using Notification activity in workflow on this table to send the content of this HTML field.

Currently I am using "HTML" type field which works fine without dynamic substitution.

These developments are in a scoped application.

Any other way to do this?

1 ACCEPTED SOLUTION

Apologies. I forgot that I disabled the reference qualifier on the type field to show all fields while doing some development earlier.



NOTE: Do not capture this in an update set! Set your application to Global and update set to Default when doing these next steps!


  1. Right click on the Type field and select Configure Dictionary.
  2. Go to the Reference Specification section and set the "Use Reference Qualifier" field to "Simple"
  3. Save the Record
  4. Now you can select HTML Script (and other types of fields)


find_real_file.png


View solution in original post

20 REPLIES 20

I'd have to know more about how you are getting the HTML from the custom table in to your notification. The variable substitution happens in the email message, not in fields that the email is referencing (double substitution if you will.)

what I am doing is, I have a notification for Table x and I added in the template mail script: email.setBody(current.body);

so now in the Table X Form I have a Field type Table and have the reference of the Table X. 

I have also the HTML Script with dependent on that Table Field I have created.

Now I just then added in the HTML Body on the form ${Variable X} .

 

Elias 

If I understand you correctly, you have an HTML script field that has meta strings like ${number} and you have a notification that is getting the content from your HTML script field something like this: ${html_script}

The notification will bring in the content of the html_script field as it should, but the system is not designed to parse and replace meta strings within the content of that field as well. There's no "double replacement" to recognize ${number} in the HTML and replace it with a value of some other record. It would be ambiguous which table/record that ${number} represents.

Let me know if I've misunderstood the requirement or your setup.

Yep indeed, you got it, I am getting the Content from my HTML script into my notification per current.html_script or so. 

but yes I understand now the issue.

I assumed that so but I wasnt sure.

 

Is there any alternative?

 

My Idea is just to split the HTMl Script Field into many fields that I Need, and getting them together in the mail script notifcation.

 

I was hopping to have something in my HTML Script to get only the SysId of the users Field that I have in the form, 

and put it into an URL. so it will be something like that in the HTML Body: www.myinstancename.com/?id=MyPage&sys_id=current.user 

 

but I am not able to get the current user into the html script field.

 

Cheers

Elias

You would have to write your own script to do replacement on the meta strings. I've done this, it's a bit of a find/replace exercise in script. Mine tend to be very bespoke where I identify the known keywords and what text is replaced. I don't do any dictionary lookups or display values.

An example from a recent script include:

	replaceMeta : function (episodeGr, text) {
		
		var newText = text;
		// gs.info('text=' + text);
		var patt = /(\${[a-z_]*})/g;
		var list = text.match(patt);
		
		if (!list) {
			gs.warn('No meta strings found in: ' + text);
			return text;
		}
		
		if (list.length == 0) {
			return text;
		}
		
		// gs.info('list.length=' + list.length);
		
		for (var i = 0; i < list.length; i++) {
			// gs.info('found: ' + list[i]);
			switch (list[i]) {
				case '${html_topic_list}':
					newText = text.replace(list[i], this._generateHTMLList(episodeGr));
					break;
				case '${youtube_id}':
					if (episodeGr.youtube_url) {
						newText = text.replace(list[i], this._getYouTubeID(episodeGr.getValue('youtube_url')));						
					}
					break;
				case '${text_topic_list}':
					newText = text.replace(list[i], this._generateTextList(episodeGr));
					break;
										
				case '${repo_url}':
					var repo = gs.getProperty('x_snc_cls.repo_name');
					if (episodeGr.has_git) {
						var url = repo + '/tree/master/' + episodeGr.date.getDisplayValue();
						newText = text.replace(list[i], url);
					} else {
						newText = text.replace(list[i], repo);
					}
					break;
					
				case '${date}':
					var dateStr = episodeGr.date.getDisplayValue();
					newText = text.replace(list[i], dateStr);
					break;
					
				case '${community_url}':
					if (episodeGr.community_url) {
						newText = text.replace(list[i], episodeGr.getValue('community_url'));
					}
					break;
			}
			
			text = newText;
		}
		
		return text;
		
	},