I am new to ARS, so please forgive my ignorance.
I have create several Cascading Drop Down Lists the the ARS Web Interface, and they are working fine.
One of the Drop Down List is assigned to the "physicalDeliveryOfficeName" attribute. (See Complete Script Below)
What I am trying to do, is after the user record is modified, use an SQL query to lookup the corresponding City, State, Country and Country Code for the selected Location.
I have set up one other policy to combine the Division and " - " and Department and assign that value to the o "Organization" attribute. It works fine, but I am not using any scripting.
I think I have set up the policy correctly, assinged it to my "Manged Users" OU. I selected script for modify and it gave me the begining and ending lines:
Sub onPostModify(Request)
EndSub
I have gleaned the rest of my code from other VBS I have written along with examples from the ARS Community.
The following Script does not have any complilation errors when I save it to the Server, it just doesn't work.
I stripped out the Active Directory part and hard coded the "Where Location = '"& ULoc & "' "
part of the code and commented out the
ULoc = Request.Get("physicalDeliveryOfficeName")
and the
Request.SetEffectivePolicyInfo "l", EDS_EPI_UI_GENERATED_VALUE, GetCity
Request.SetEffectivePolicyInfo "st", EDS_EPI_UI_GENERATED_VALUE, GetState
Request.SetEffectivePolicyInfo "co", EDS_EPI_UI_GENERATED_VALUE, GetCountry
Request.SetEffectivePolicyInfo "c", EDS_EPI_UI_GENERATED_VALUE, GetCountryCode
Statements.
I then ran the script in Windows and had it display the GetCity, GetState, GetCountry, GetCountryCode varibles.
It worked fine, so I know that the SQL part of the Script is OK.
So either I am not assigning the variable ULoc correctly or my statements to set the attributes are wrong.
if that is all good, then I guess I have not applied the script correctly.
When I use the WI to open and modify a User Object and Change the Location Drop Down, it saves fine, but it does not update the City, State and Country as it is suppoesed to.
Any help would be greatly appriciated.
Thanks,
AD
Sub onPostModify(Request)
If Request.Class <> "user"ThenExitSub
' connection and recordset variables
Dim Cnxn
Dim strCnxn
Dim rs
Dim strSQL
Dim ULoc
Dim GetCity, GetState, GetCountry, GetCountryCode
'*******************************************************************************************************
ULoc = Request.Get("physicalDeliveryOfficeName")
' open connection
Set Cnxn = CreateObject ("ADODB.Connection")
strCnxn = "Provider=sqloledb;Data Source=MyServer;Initial Catalog=ADLookup;User Id=MyUser;Password=MyPwd;"
Cnxn.Open strCnxn
' create and open Recordset using object refs
Set rs = CreateObject("ADODB.Recordset")
strSQL = "SELECT Location, City, State, Country, CountryCode, CountryAbriviation "
strSQL = strSQL & "FROM ADLookup.dbo.vw_Locations "
strSQL = strSQL & "Where Location = '"& ULoc & "' "
rs.ActiveConnection = Cnxn
rs.Source = strSQL
rs.Open
'*******************************************************************************************************
IfNot(rs.bof And rs.EOF) then
rs.MoveFirst
GetCity = rs.FIELDs(1).value
GetState = rs.FIELDs(2).value
GetCountry = rs.FIELDs(3).value
GetCountryCode = rs.FIELDs(4).value
Request.SetEffectivePolicyInfo "l", EDS_EPI_UI_GENERATED_VALUE, GetCity
Request.SetEffectivePolicyInfo "st", EDS_EPI_UI_GENERATED_VALUE, GetState
Request.SetEffectivePolicyInfo "co", EDS_EPI_UI_GENERATED_VALUE, GetCountry
Request.SetEffectivePolicyInfo "c", EDS_EPI_UI_GENERATED_VALUE, GetCountryCode
Endif
rs.close
Cnxn.close
EndSub