The CreatorCon Call for Content is officially open! Get started here.

source.sys_import_state_comment display empty

CKJ-BeOS
Tera Contributor

Hi,

 

On Transorm Map into an "OnAfter" script, i use the "source.sys_import_state_comment" to display information about the action, but in result Import set the information is empty.

It is working or not into onAfter script ?

 

Regards,

Cédric

7 REPLIES 7

sizzleMcFace
Giga Guru

Hi,

 

What exactly are you using source.sys_import_state_comment for in the onAfter script? Are you trying to set it or read it?

 

The "sys_import_state_comment" field is managed by the system and is used to store comments about the import state of each row. Typically, you can write to it in onBefore or onEach scripts to set status messages for rows during transformation. If your goal is to log or display import comments, you should do it in onBefore or onEach script. In onAfter, you usually work with the target record, not the import set row.

 

If you need to preserve comments from source for auditing, consider copying them to a target field during transformation, because sys_import_state_comment may no longer be reliable in onAfter.

Hi, thanks

I undrstand, i need to be onAfter because need the record on insert action exist, i would like to add information to give the last action made into onAfter is succesfull.

 

Regards,

Cedric

I believe in that case you will have to do something like:

 

if target.operation==“insert”

target.field_name= “inserted”


Raghav
MVP 2023
LinkedIn

Here my code to explain

I just want to give feedback about what is made or not onAfter execution :

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ )
{
	// here we check if we are a user assignment
	if(ignore==false)
	{
		if(source.u_user!=undefined && source.u_user!="")
		{
			grUser = new GlideRecord("sys_user");
			grUser.addEncodedQuery("user_name="+source.u_user);
			grUser.query();

			// we need to find user
			// to assign the current Locker
			if(grUser.next())
			{
				// locker is used (751 = "Non Libre")
				target.u_availability = "751";

				// assign user
				grUser.u_locker = target.sys_id;
				grUser.update();

				// give information that's locker is released
				source.sys_import_state_comment = "Locker ["+target.name+"] assigned to user ["+grUser.user_name+"]";
			}
			else
			{
				// just inform that the user not fond
				source.sys_import_state_comment = "User ["+source.u_user+"] not fond for locker ["+target.name+"]";
			}
		}
		else
		{
			// user is empty that's would possible we need to empty locker from user
			// check if the action to force empty is needed
			// this action can be used only on update existing locker and user
			if(source.u_forceempty.toUpperCase()=="TRUE" && action!="insert")
			{
				grUser = new GlideRecord("sys_user");
				grUser.addEncodedQuery("u_locker="+target.sys_id);
				grUser.query();

				// we need to find user
				// to remove the locker
				if(grUser.next())
				{
					// locker is released value set to "1"
					target.u_availability = "1";

					// assign user
					grUser.u_locker = "";
					grUser.update();

					// give information that's locker is released
					source.sys_import_state_comment = "Locker ["+target.name+"] assigned to ["+grUser.user_name+"] is released";
				}
				else
				{
					// just inform that the user not fond
					source.sys_import_state_comment = "Locker ["+target.name+"] not assigned to a user";
				}			
			}
		}
	}

})(source, map, log, target);