Roku (Brightscript) - Playing DRM Protected Video Content - drm

These is a self answering question.
Problem:
Can not play videos which are protected by PlayReady DRM.

Here is the working sample
if m.VideoPlayer = invalid
m.VideoPlayer = m.top.createChild("Video")
m.VideoPlayer.id = "VideoPlayer"
m.VideoPlayer.observeField("state", "OnVideoStateChange")
end if
drmParams = {}
videoContent = createObject("RoSGNode", "ContentNode")
videoContent.Live = remoteContent.IsLive
videoContent.Url = remoteContent.Path
if remoteContent.CodecType = "DashWideVineDrm" then
videoContent.StreamFormat = "dash"
drmparams.licenseServerURL = remoteContent.DrmRightsUrl
drmParams.KeySystem = "widevine"
else if remoteContent.CodecType = "PlayReadyDrm" then
videoContent.StreamFormat = "ism"
drmParams.KeySystem = "playready"
drmParams.encodingType = "PlayReadyLicenseAcquisitionUrl"
drmParams.encodingKey = remoteContent.DrmRightsUrl
else
videoContent.StreamFormat = "mp4"
end if
videoContent.drmParams = drmParams
device = CreateObject("roDeviceInfo")
httpAgent = CreateObject("roHttpAgent")
if httpAgent <> invalid then
httpAgent.SetCertificatesFile("common:/certs/ca-bundle.crt")
httpAgent.InitClientCertificates()
httpAgent.EnableCookies()
httpAgent.AddHeader("X-Roku-Reserved-Dev-Id", "")
if remoteContent.MYCUSTOMHEADER1 <> invalid and remoteContent.MYCUSTOMHEADER1 <> "" then
httpAgent.AddHeader("MY-CUSTOM-HEADER2", remoteContent.MYCUSTOMHEADER1)
end if
if remoteContent.MYCUSTOMHEADER2 <> invalid and remoteContent.MYCUSTOMHEADER2 <> "" then
httpAgent.AddHeader("MY-CUSTOM-HEADER2", remoteContent.MYCUSTOMHEADER2)
end if
m.VideoPlayer.setHttpAgent(httpAgent)
else
headers = []
headers.push("X-Roku-Reserved-Dev-Id:")
if remoteContent.MYCUSTOMHEADER1 <> invalid and remoteContent.MYCUSTOMHEADER1 <> "" then headers.push("MY-CUSTOM-HEADER1:" + remoteContent.MYCUSTOMHEADER1)
if remoteContent.MYCUSTOMHEADER2 <> invalid and remoteContent.MYCUSTOMHEADER2 <> "" then headers.push("MY-CUSTOM-HEADER2:" + remoteContent.MYCUSTOMHEADER2)
videoContent.HttpHeaders = headers
videoContent.HttpSendClientCertificates = true
videoContent.HttpCertificatesFile = "common:/certs/ca-bundle.crt"
m.VideoPlayer.EnableCookies()
m.VideoPlayer.SetCertificatesFile("common:/certs/ca-bundle.crt")
m.VideoPlayer.InitClientCertificates()
end if
m.VideoPlayer.content = videoContent
m.VideoPlayer.control = "play"
NOTE:
If you use PlayReady DO NOT FILL drmParams.licenseServerURL, because it will fail to play with DRM Error (-6).

Related

How to prompt for user info for a key in a map type variable in Terraform

I have the following variable in terraform:
rds_config_list = [
{
rds_name = "shiftleft"
rds_identifier = "shiftleft-postgres"
rds_password = <USETINPUT>
rds_snapshot_identifier = "shiftleft"
rds_postgres_instance_class = "db.m6g.large"
rds_postgres_engine_version = "13.3"
rds_postgres_family = "postgres13"
rds_postgres_allocated_storage = 100
rds_postgres_max_allocated_storage = 1000
rds_backup_retention_period = 7
rds_postgres_multi_az = false
rds_postgres_deletion_protection = false
},
{
rds_name = "shiftleft2"
rds_identifier = "shiftleft2-postgres"
rds_password = <USETINPUT>
rds_snapshot_identifier = "shiftleft2"
rds_postgres_instance_class = "db.m6g.large"
rds_postgres_engine_version = "13.3"
rds_postgres_family = "postgres13"
rds_postgres_allocated_storage = 100
rds_postgres_max_allocated_storage = 1000
rds_backup_retention_period = 7
rds_postgres_multi_az = false
rds_postgres_deletion_protection = false
}
]
i want to prompt for user input for the passwords for each of them and not have the same password for all databases, this is inside a .tfvars file. is there any way to do it?

Ommit optional blocks in terraform module

Currently I'm trying to create a universal sql_database module in Terraform. I want to have control over arguments I want to include in this resource. For example one time I need only required arguments but next time in another project I need them plus threat_detection_policy block with all nested arguments.
modules/sql_database.tf
resource "azurerm_sql_database" "sql-db" {
name = var.sql-db-name
resource_group_name = data.azurerm_resource_group.rg-name.name
location = var.location
server_name = var.server-name
edition = var.sql-db-edition
collation = var.collation
create_mode = var.create-mode
requested_service_objective_name = var.sql-requested-service-objective-name
read_scale = var.read-scale
zone_redundant = var.zone-redundant
extended_auditing_policy {
storage_endpoint = var.eap-storage-endpoint
storage_account_access_key = var.eap-storage-account-access-key
storage_account_access_key_is_secondary = var.eap-storage-account-access-key-is-secondary
retention_in_days = var.eap-retention-days
}
import = {
storage_uri = var.storage-uri
storage_key = var.storage-key
storage_key_type = var.storage-key-type
administrator_login = var.administrator-login
administrator_login_password = var.administrator-login-password
authentication_type = var.authentication-type
operation_mode = var.operation-mode
}
threat_detection_policy = {
state = var.state
disabled_alerts = var.disabled-alerts
email_account_admins = var.email-account-admins
email_addresses = var.email-addresses
retention_days = var.retention-days
storage_account_access_key = var.storage-account-access-key
storage_endpoint = var.storage-endpoint
use_server_default = var.use-server-default
}
}
modules/variables.tf (few sql_database vars)
variable "sql-db-edition" {
type = string
}
...
variable "state" { #for example this should be optional
type = string
}
...
main.tf
module "sql_database" {
source = "./modules/sql_database"
sql-db-name = "sqldbs-example"
location = "westus"
server-name = "sqlsrv-example"
storage-uri = "" #some values
storage-key = ""
storage-key_type = ""
administrator-login = ""
administrator-login-password = ""
authentication-type = ""
operation-mode = ""
sql-db-edition = "Standard"
collation = "SQL_LATIN1_GENERAL_CP1_CI_AS"
create-mode = "Default"
sql-requested_service_objective_name = "S0"
requested_service_objective_id = ""
read-scale = "false"
zone_redundant = ""
source_database_id = ""
restore_point_in_time = ""
max_size_bytes = ""
source_database_deletion_date = ""
elastic_pool_name = ""
#variables below should be all optional
state = ""
disabled_alerts = ""
email_account_admins = ""
email_addresses = ""
retention_days = 6
storage_account_access_key = ""
storage_endpoint = ""
use_server_default = ""
storage_endpoint = ""
storage_account_access_key = ""
storage_account_access_key_is_secondary = "false"
retention_in_days = 6
}
Thank you in advance for help!
For your requirements, I think a possible way is to set the default values inside the module and make the default values act as you do not set them. For example, in the threat_detection_policy block, the property use_server_default, when you do not set it, the default value is Disabled. And when you want to set them, just input the values in the module block.

Automate copy paste Excel ranges dynamically from different sheets

I have tables in different sheets of excel and requirement is to copy second last row of table to last row. Can someone pls help me how can we dynamically find table size so that code wont be required to change evrytime when table size changes? There are many tables and we want to automate this task using vba code and macro button.
I have written a code but that is range specific and everytime I need to update the range and process become cumbersome.
Sub history_copy()
Set obj = ActiveWorkbook.Sheets("sheet A")
obj.Range("E12:N12").Value = obj.Range("E11:N11").Value
obj.Range("E34:N34").Value = obj.Range("E33:N33").Value
obj.Range("E46:N46").Value = obj.Range("E45:N45").Value
obj.Range("E57:N57").Value = obj.Range("E56:N56").Value
Set obj1 = ActiveWorkbook.Sheets("sheet b ")
obj1.Range("G21:O21").Value = obj1.Range("G20:O20").Value
Set obj2 = ActiveWorkbook.Sheets("sheet c")
obj2.Range("D4:M4").Value = obj2.Range("D3:M3").Value
obj2.Range("D14:M14").Value = obj2.Range("D13:M13").Value
obj2.Range("D23:M23").Value = obj2.Range("D22:M22").Value
obj2.Range("D33:M33").Value = obj2.Range("D32:M32").Value
obj2.Range("D43:M43").Value = obj2.Range("D42:M42").Value
obj2.Range("D52:M52").Value = obj2.Range("D51:M51").Value
obj2.Range("D61:M61").Value = obj2.Range("D60:M60").Value
obj2.Range("D70:M70").Value = obj2.Range("D69:M69").Value
obj2.Range("D79:M79").Value = obj2.Range("D78:M78").Value
obj2.Range("D88:M88").Value = obj2.Range("D87:M87").Value
obj2.Range("D97:M97").Value = obj2.Range("D96:M96").Value
obj2.Range("D106:M106").Value = obj2.Range("D105:M105").Value
obj2.Range("D114:M114").Value = obj2.Range("D113:M113").Value
Set obj3 = ActiveWorkbook.Sheets("sheet d")
obj3.Range("D4:L4").Value = obj3.Range("D3:L3").Value
Set obj5 = ActiveWorkbook.Sheets("sheet f")
obj5.Range("D4:L4").Value = obj5.Range("D3:L3").Value
Set obj6 = ActiveWorkbook.Sheets("sheet e")
obj6.Range("C4:C12").Value = obj6.Range("B4:B12").Value
obj6.Range("H4:H8").Value = obj6.Range("G4:G8").Value
obj6.Range("N4:N11").Value = obj6.Range("M4:M11").Value
obj6.Range("S4:S10").Value = obj6.Range("R4:R10").Value
obj6.Range("X4:X18").Value = obj6.Range("W4:W18").Value
obj6.Range("AD4:AD9").Value = obj6.Range("AC4:AC9").Value
obj6.Range("AI4:AI13").Value = obj6.Range("AH4:AH13").Value
obj6.Range("AO4:AO6").Value = obj6.Range("AN4:AN6").Value
obj6.Range("AT4:AT11").Value = obj6.Range("AS4:AS11").Value
obj6.Range("AY4:AY20").Value = obj6.Range("AX4:AX20").Value
obj6.Range("BD4:BD10").Value = obj6.Range("BC4:BC10").Value
obj6.Range("BI4:BI21").Value = obj6.Range("BH4:BH21").Value
Set obj7 = ActiveWorkbook.Sheets("sheet i")
obj7.Range("C4:C12").Value = obj7.Range("B4:B12").Value
obj7.Range("H4:H8").Value = obj7.Range("G4:G8").Value
obj7.Range("N4:N11").Value = obj7.Range("M4:M11").Value
obj7.Range("S4:S10").Value = obj7.Range("R4:R10").Value
obj7.Range("X4:X18").Value = obj7.Range("W4:W18").Value
obj7.Range("AD4:AD9").Value = obj7.Range("AC4:AC9").Value
obj7.Range("AI4:AI13").Value = obj7.Range("AH4:AH13").Value
obj7.Range("AO4:AO6").Value = obj7.Range("AN4:AN6").Value
obj7.Range("AT4:AT11").Value = obj7.Range("AS4:AS11").Value
obj7.Range("AY4:AY20").Value = obj7.Range("AX4:AX20").Value
obj7.Range("BD4:BD10").Value = obj7.Range("BC4:BC10").Value
obj7.Range("BI4:BI21").Value = obj7.Range("BH4:BH21").Value
End Sub

Microsoft Excel is waiting for another application to complete an OLE action after 63rd loop

I've been using the following script to run Agent trace reports on call center agents daily for our primary call center site, which has between 40 and 50 agents at any given time. I'm now expanding this reporting to our other sites, having to run the report for 234 agents at a time. I tried setting the loop for the full list of 234 agents, and after the 63rd agent is completed, I get the OLE error.
I've tried adding 'DoEvents" and 'Application.Wait' throughout the code to slow things down a bit and to ensure that the process completes before the next starts , I've also broken up the code from 1 loop of 234 into 4 loops of 60 (the last loop is only 54 for you math junkies), but I'm still getting the OLE error after agent 63 completes.
How can I determine what is causing this OLE error?
Sub CMSConn()
Dim cvsApp As Object
Dim cvsConn As Object
Dim cvsSrv As Object
Dim Rep As Object
Dim Info As Object, Log As Object, b As Object
Dim Agents(234) As String
Dim I As Integer
Set wk = ThisWorkbook
serverAddress = "xxx.xxx.xxx.xxx"
mydate = InputBox("Dates: ")
UserName = InputBox("User ID: ")
passW = InputBox("Password: ")
Agents(1) = "Abcede, Ronaldo"
Agents(2) = "Abella, Poltaqn"
Agents(3) = "Ablen, Armie"
Agents(4) = "Abon, Sherry Lou"
Agents(5) = "Acbang, MaryJane"
Agents(6) = "Acbang, MaryJane"
Agents(7) = "Alcantara, Luis Jaim"
Agents(8) = "Alfaro, Nio"
Agents(9) = "Aman, Sherwin"
Agents(10) = "Amar, Catherine"
Agents(11) = "Amor, Charlie"
Agents(12) = "Anonuevo, Hubert"
Agents(13) = "Antonio, Brian Antho"
Agents(14) = "Antonio, Diana Grace"
Agents(15) = "Aragon, Ramiro"
Agents(16) = "Araullo, Keith"
Agents(17) = "Arevalo, Jerome"
Agents(18) = "Arnel Decano"
Agents(19) = "Arriola, Paulo"
Agents(20) = "Asturias, Sheena"
Agents(21) = "Baguhin, Kathrin May"
Agents(22) = "Balatbat, Lauro"
Agents(23) = "Balena, Nathan"
Agents(24) = "Ballos, Evelyn"
Agents(25) = "Banaban, Nona"
Agents(26) = "Bansale, Jemma"
Agents(27) = "Bautista, Bernie"
Agents(28) = "Bautista, Domingo J"
Agents(29) = "Belen, Michelle"
Agents(30) = "Bicaldo, Catherine"
Agents(31) = "Bonifacio, Allan"
Agents(32) = "Borbon, Danny"
Agents(33) = "Brian Patrick Roxas"
Agents(34) = "Bundalian, Kristel J"
Agents(35) = "Bundalian, Paul"
Agents(36) = "Cabasa, Aidel Joy"
Agents(37) = "Cabauatan, Jacquelin"
Agents(38) = "Caldina, Joanne Nico"
Agents(39) = "Calumpiano, Jean"
Agents(40) = "Camarao, Maria There"
Agents(41) = "Capucao, Daisy"
Agents(42) = "Carpio, Rusell"
Agents(43) = "Caunca, Michael John"
Agents(44) = "Cequeña, Dianne"
Agents(45) = "Chinen, Jeffrey"
Agents(46) = "Chrisgeena Clemeno"
Agents(47) = "Clarin, Marco Leandr"
Agents(48) = "Clauag, Martin Paul"
Agents(49) = "Corbilla. Marcel"
Agents(50) = "Cruz, Cherrimei"
Agents(51) = "Cruz, Geran Judeth"
Agents(52) = "Cruz, Lorreine"
Agents(53) = "Cuaresma Sheila Mari"
Agents(54) = "Cudiamat, Catherine"
Agents(55) = "Cudiamat, Paul"
Agents(56) = "Cueva, Ruthie"
Agents(57) = "Dalida, Rowell"
Agents(58) = "De Guzman, Jennelyn"
Agents(59) = "De Vera, Chris Evert"
Agents(60) = "DeGuzman, Aubrey"
Agents(61) = "DeGuzman, Noel"
Agents(62) = "Del Monte, Mark"
Agents(63) = "Dela Fuente, Herner"
Agents(64) = "Dela Mesa, Randy"
Agents(65) = "Delape Jr., Evelio"
Agents(66) = "10404"
Agents(67) = "Delos Santos, Ervin"
Agents(68) = "Diaz, Jerosalem"
Agents(69) = "Diaz, Leila Ruth"
Agents(70) = "Dicen, Melanie"
Agents(71) = "Dimailig, Kenneth"
Agents(72) = "Dizon, Marc Anthony"
Agents(73) = "Doblas, Leora"
Agents(74) = "Domingo, Rafael"
Agents(75) = "Dulay, Susana Marie"
Agents(76) = "Dy, Jerwin"
Agents(77) = "Elnas, Bernadette"
Agents(78) = "Elnas, Elsha Marie"
Agents(79) = "Enumerable, Gary"
Agents(80) = "Escobal, Aubrey"
Agents(81) = "Escorpion, Genix"
Agents(82) = "Espaldon, Eveleen"
Agents(83) = "Esquivel, Jean Paul"
Agents(84) = "Estabillo,Reygienald"
Agents(85) = "Esteban, Aaron Paul"
Agents(86) = "Esteban, Richard"
Agents(87) = "Fe Marie Jopia"
Agents(88) = "Fermin, Maricris"
Agents(89) = "Fresado, Marie"
Agents(90) = "Gagarin, Wilson"
Agents(91) = "Galero, Roxanne"
Agents(92) = "Gamboa, Aleli"
Agents(93) = "Garcia, Jayson"
Agents(94) = "Garcia, Rey"
Agents(95) = "Garganta, Angelie"
Agents(96) = "Gepolane, Jacinth Ka"
Agents(97) = "Geroche, Raul"
Agents(98) = "Gilera, Erwin"
Agents(99) = "Go, Mark Dexter"
Agents(100) = "Godillo, Albert"
Agents(101) = "Grospe, Noemi"
Agents(102) = "Gualin, Raymond"
Agents(103) = "Guela, Antonette"
Agents(104) = "Guevarra, Randy"
Agents(105) = "Guiang, Mary Paula"
Agents(106) = "Gumera, Diana Corina"
Agents(107) = "Hernandez, Jules"
Agents(108) = "Hora, Gene Patrick"
Agents(109) = "Hu Kwong Man"
Agents(110) = "Iballar, Maria Chris"
Agents(111) = "Ignacio, Florabel"
Agents(112) = "Ilaga, Eunice"
Agents(113) = "Inovero, Michelle"
Agents(114) = "Ismail, Amir"
Agents(115) = "Jaen, Ritchiedel"
Agents(116) = "Jimeno, Evita"
Agents(117) = "Joanne Marie Sai"
Agents(118) = "John Michael Abellar"
Agents(119) = "Julian, Desiree"
Agents(120) = "Justine Joy Lucban"
Agents(121) = "Justiniano, Eufraime"
Agents(122) = "Karen Cathley Digman"
Agents(123) = "Lamparas, Nenita"
Agents(124) = "Laxa, Catherine"
Agents(125) = "Lecoto, Vener"
Agents(126) = "Leuterio, Ilene"
Agents(127) = "Limbo, Karen"
Agents(128) = "Lingad, Raymond"
Agents(129) = "Liza, Joseph Jay"
Agents(130) = "Lomongo, Wilbert"
Agents(131) = "Loreto, Aguilar"
Agents(132) = "Lugtu , Jude"
Agents(133) = "Luzon, Liza"
Agents(134) = "Ma. Eleonor Tabing"
Agents(135) = "Mabborang, Queenly"
Agents(136) = "Mabini, Eve"
Agents(137) = "Macababda, Marijo"
Agents(138) = "Macutay, Charlotte"
Agents(139) = "Macutay, Mark Anthon"
Agents(140) = "Magtangob, Julius"
Agents(141) = "Manago, Roman Carlo"
Agents(142) = "Manaloto, Marlon"
Agents(143) = "Mangaoang, Carmel Ri"
Agents(144) = "Mapolon, Amie"
Agents(145) = "Martin, Maricar"
Agents(146) = "Martin, Sharon"
Agents(147) = "Mendoza, Dann Kristo"
Agents(148) = "Mendoza, Liezl"
Agents(149) = "Mesias, Hannah"
Agents(150) = "Miranda, Nicola Elan"
Agents(151) = "Miranda, Sheila"
Agents(152) = "Mirandilla, Paulo"
Agents(153) = "Mislang Jr., Roberto"
Agents(154) = "Montances, Raquel"
Agents(155) = "Montefalcon, Erliza"
Agents(156) = "Munar, Rommel"
Agents(157) = "Naluz, Alexis Viktor"
Agents(158) = "Narbuada, Norman"
Agents(159) = "Nirza, Miguel"
Agents(160) = "Orteza, Gian Carlo"
Agents(161) = "Oteyza, Karen Rosell"
Agents(162) = "Panganiban, Karina"
Agents(163) = "Panganiban, Leah"
Agents(164) = "Papina, Roland"
Agents(165) = "Parel, Rose Ann Chri"
Agents(166) = "Parra, Nimfa"
Agents(167) = "Pascua, Ramon"
Agents(168) = "Pasuquin, Mary Grace"
Agents(169) = "Pauig, Sue Laine"
Agents(170) = "Perlas, Joby Jade"
Agents(171) = "Poñado, Rachal"
Agents(172) = "Puli, Ivan"
Agents(173) = "Pumar, Elora Ann"
Agents(174) = "Quintos, Stephen Ed"
Agents(175) = "Ramirez, Requel"
Agents(176) = "Ramos, Eumir"
Agents(177) = "Ramos, Rosemarie."
Agents(178) = "Rarangol, Jane"
Agents(179) = "Rebugio, Mark Joseph"
Agents(180) = "Reotutar, Neil Clark"
Agents(181) = "Resurreccion, Aimee"
Agents(182) = "Reyes, Lymuel"
Agents(183) = "Ricafranca, Nikolai"
Agents(184) = "Rino, Kim Eric"
Agents(185) = "Rioja, Daisy"
Agents(186) = "Robidillo, Fatima"
Agents(187) = "Rolando Lindog"
Agents(188) = "Romero, Darling"
Agents(189) = "Rosas, Bryan Carlo"
Agents(190) = "Rowena Rona"
Agents(191) = "Sacrez, Ma Aurora"
Agents(192) = "Sai, Joanna Marie"
Agents(193) = "Salvacion, Fairodz b"
Agents(194) = "Salvador Jr, Rolando"
Agents(195) = "Santibanez, Norman"
Agents(196) = "Santos, Mayleen Sa"
Agents(197) = "Saribay, Mark"
Agents(198) = "Saulog, Giovannie"
Agents(199) = "Seludo, Loida"
Agents(200) = "Sereno, Marjorie"
Agents(201) = "Serrano, Zacheus"
Agents(202) = "Sheremeil Tan"
Agents(203) = "Silverio II, Carlo"
Agents(204) = "Tambobong , Regina"
Agents(205) = "Tan, Boon Beng"
Agents(206) = "Tapia, Dianne Andrea"
Agents(207) = "Tingzon, Jan Therese"
Agents(208) = "Tolentino, Glennford"
Agents(209) = "Tolentino, Rodney"
Agents(210) = "Tolosa, Joy Maru"
Agents(211) = "Tolosa, Rod Jeffrey"
Agents(212) = "Toong, Rene"
Agents(213) = "Torilla, Nathaniel"
Agents(214) = "Tort, Mary Grace"
Agents(215) = "Trinidad, Francis"
Agents(216) = "Tubice, Janette"
Agents(217) = "Tudlasan, Mary Jo"
Agents(218) = "Tuguib, Rodney"
Agents(219) = "Tulawan, Joedelyn"
Agents(220) = "Uy, Gretchen Mari St"
Agents(221) = "Valebia, Kristine"
Agents(222) = "Valenzuela, Demsey"
Agents(223) = "Valenzuela, Myles"
Agents(224) = "Vargas, Christine"
Agents(225) = "Vargas, Jose"
Agents(226) = "Villanueva, Marcelle"
Agents(227) = "Villanueva, Vigie"
Agents(228) = "Villaver, Conrado"
Agents(229) = "Virtudazo, Joeurbett"
Agents(230) = "Viscante, Emelson"
Agents(231) = "Yap, Paul"
Agents(232) = "Ylagan, Celin"
Agents(233) = "Ylidon, Andrew"
Agents(234) = "Yrrverre, Neil Vince"
Set cvsApp = CreateObject("ACSUP.cvsApplication")
Set cvsConn = CreateObject("ACSCN.cvsConnection")
Set cvsSrv = CreateObject("ACSUPSRV.cvsServer")
Set Rep = CreateObject("ACSREP.cvsReport")
For I = 1 To 234
agentName = Agents(I)
If cvsApp.CreateServer(UserName, "", "", serverAddress, False, "ENU", cvsSrv, cvsConn) Then
If cvsConn.login(UserName, passW, serverAddress, "ENU") Then
On Error Resume Next
cvsSrv.Reports.ACD = 1
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Set Info = cvsSrv.Reports.Reports("Historical\Agent\Trace by Location")
If Info Is Nothing Then
If cvsSrv.Interactive Then
MsgBox "The Report " & "Historical\Agent\Trace by Location" & " was not found on ACD 1", vbCritical Or vbOKOnly, "CentreVu Supervisor"
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Else
Set Log = CreateObject("ACSERR.cvslog")
Log.AutoLogWrite "The Report " & "Historical\Agent\Trace by Location" & " was not found on ACD 1"
Set Log = Nothing
End If
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Else
b = cvsSrv.Reports.CreateReport(Info, Rep)
If b Then
Debug.Print Rep.SetProperty("Agent", Agents(I)) ' agentName)
Debug.Print Rep.SetProperty("Dates", mydate)
Debug.Print Rep.SetProperty("Times", "00:00-23:59")
b = Rep.ExportData("", 9, 0, False, True, True)
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
wk.Sheets(I).Select
wk.Sheets(I).Cells.ClearContents
wk.Sheets(I).Cells(1, 1).PasteSpecial
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
Set Rep = Nothing
Set Log = Nothing
Set Rep = Nothing
Set cvsSrv = Nothing
Set cvsConn = Nothing
Set cvsApp = Nothing
Set Info = Nothing
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
End If
End If
End If
End If
ActiveWorkbook.Save
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Next I
cvsConn.logout
cvsConn.Disconnect
cvsSrv.Connected = False
DoEvents
MsgBox "Completed"
End Sub

How to inset a customer location through graph

Hello I am banging my head against the wall trying find the correct way to insert a customer location using a graph. I am currently using the PX.Objects.CR.CustomerLocationMaint graph. But when I insert or set current location it is always null.
Here is my code
private PX.Objects.CR.Location UpdateCustomerLocation(PX.Objects.AR.Customer cust, ListingRead currentListing, ListingContactRelnListing contact)
{
PX.Objects.AR.CustomerLocationMaint g = new PX.Objects.AR.CustomerLocationMaint();
g.Clear(PXClearOption.ClearAll);
g.BusinessAccount.Current = cust;
PX.Objects.CR.Location loc = new PX.Objects.CR.Location();
loc.BAccountID = cust.BAccountID;
loc.LocationCD = "RL" + contact.contact.id;
loc.Descr = currentListing.property.system_search_key;
loc.DefContactID = cust.DefContactID;
loc.IsActive = true;
loc.LocType = "CU";
g.Location.Current = loc;
loc = g.Location.Insert(loc);
PX.Objects.CR.Address addr = new PX.Objects.CR.Address();
addr.BAccountID = cust.BAccountID;
addr.AddressType = "BS";
addr.CountryID = "NZ";
addr.AddressLine1 = currentListing.property.adr_street_number + " " + currentListing.property.adr_street_name;
addr.AddressLine2 = currentListing.property.adr_suburb_or_town;
addr.AddressLine3 = currentListing.property.adr_state_or_region;
addr = g.Address.Insert(addr);
loc.DefAddressID = addr.AddressID;
g.Location.Update(loc);
g.Actions.PressSave();
return loc;
}

Resources