Switching Objects within a Script
Are we able to switch an called-upon object in a script?
For example, this script works to send a notification email User2 after doing a Save As on User1. The script sends a notification to User2 but works off of the original object, User1.
Is there any good way to switch this so that the script not only sends a notification to User2 but works off of User2 for the object? That way I can use things like [General.Info First Name] for User2 email instead of User1.
import com.agile.agileDSL.ScriptObj.*;
import com.agile.agileDSL.ScriptObj.AgileDSLException;
import com.agile.agileDSL.ScriptObj.IBaseObjectScriptObj;
import com.agile.api.*
void invokeScript(IBaseScriptObj obj) {
String newNumber = obj.getNewNumber()
IAgileSession session = obj.getAgileSDKSession();
IUser newuser3 = (IUser) session.getObject(UserConstants.CLASS_USER, newNumber);
sendToList = [newNumber];
obj.sendNotification(“New User Account Created”, false, sendToList, “Comments: send from Script handler”);
//I already tried newNumber. and newuser3. in place of obj. in the above line, just so you know.
obj.logMonitor( “New User Account Created info sent to: ” + sendToList);
}
To answer my own question, for anyone else in the future, you just have to call upon a new object. So, something like this:
String finalstring = arraylist1.join(“, “);
List notifyList = new ArrayList();
for (names in arraylist1 ) {
notifyList.add(names);
}
IUser admin = (IUser)m_session.getObject(IUser.OBJECT_TYPE, “administrator”);
m_session.sendNotification(admin, “Notice of Inactivity – Account Termination”, notifyList, false, “Agile has just notified these individuals of account inactivity:” + finalstring);
This is now switching objects and sending notification to the users in arraylist1.