Set-MediaLogEntry
- 2 Minutes to read
- Print
- DarkLight
- PDF
Set-MediaLogEntry
- 2 Minutes to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Summary
Updates an existing media log entry.
Set-MediaLogEntry
-Entry
-BypassCustomFieldValidation
Returns a media log entry object.
Parameters
Parameter | Type | Required? | Notes |
---|---|---|---|
Entry | Media Log Entry Object | Yes | |
BypassCustomFieldValidation | Switch | No, defaults to false | Ignores required field requirement for custom fields when the entry is saved. |
Examples
Update an existing media log entry
# Update an existing media log entry
# A common flow for updating existing data is to first retrieve the data using the GET
# command, update specific fields, and then provide the modified data back using the SET command.
$entry = Get-MediaLogEntry -Id 57
# Update the "Location" system field:
$entry.Location = "TX"
# Update a single choice custom field named "Media Status" to "Returned"
$mediaStatusField = $entry.Fields | Where-Object { $_.Label -eq "Media Status" }
# This is a safety check to make sure that a value exists. For example, the value object may
# not exist on a field because the custom field was added after the entry already existed.
if ($null -eq $mediaStatusField.Value) {
$mediaStatusField.Value = @{}
}
# Here, we update the 'ValueAsString' property of the value because our custom field is a text-
# based field. If this was a whole number, you would use 'ValueAsNumber', a decimal would be
# 'ValueAsDecimal', a yes/no field would be 'ValueAsBoolean', and a date field would be 'ValueAsDate'
$mediaStatusField.Value.ValueAsString = "Returned"
# We want to update a reference custom field named "Custodian" to "Albert Lloyd"
$custodianField = $entry.Fields | Where-Object { $_.Label -eq "Custodian" }
if ($null -eq $custodianField.Value) {
$custodianField.Value = @{}
}
if ($null -eq $custodianField.Value.ReferenceObject) {
$custodianField.Value.ReferenceObject = @{}
}
$custodianField.Value.ReferenceObject.Values = @(
@{
KeyAsInteger = 6
Value = "Albert Lloyd"
}
)
# Save the modified media log entry
$data = Set-MediaLogEntry -Entry $entry
# Output some information to help indicate that the media log entry was updated
Write-Output "Media log entry $($data.MediaLogEntryId) ($($data.MediaTypeName)) was updated"
# For debug purposes, convert the data to output as JSON so we can see all the fields
Write-Output ""
Write-Output "JSON Results:"
$jsonOutput = $data | ConvertTo-Json -Depth 10
# Output the data
Write-Output $jsonOutput
Execution results:
Media log entry 57 (Computer) was updated
JSON Results:
{
"MediaLogEntryId": 57,
"MediaTypeId": 9,
"MediaTypeName": "Computer",
"ProjectId": null,
"Project": null,
"ProjectDescription": null,
"TaskId": null,
"Task": null,
"TaskName": null,
"ClientId": 5,
"Client": null,
"ClientName": "Gamma Tech",
"ClientReference": "5001",
"MatterId": 8,
"Matter": null,
"MatterName": "Gamma Tech v. Zhonghua Mfg.Group",
"MatterReference": "ABC000",
"Reference": null,
"Location": "TX",
"Custodian": null,
"Notes": null,
"From": "Trisha A.",
"To": "Mark S.",
"Date": "2024-04-18T11:53:25.4510619+00:00",
"Fields": [
{
"FieldId": 23,
"ObjectId": 3,
"DataTypeId": 8,
"DataTypeName": "Single Choice",
"Label": "Media Status",
"IsRequired": false,
"Position": 0,
"Guid": 1500309138663,
"IsSystemField": false,
"IsReferenceValue": false,
"DefaultValue": "In Storage\nReturned \nDestroyed",
"CopyPreviousValueOnSaveAndNew": false,
"Value": {
"ObjectFieldValueId": 2181,
"ObjectFieldId": 23,
"ObjectId": 3,
"PrimaryKeyId": 57,
"ValueAsString": "Returned",
"ValueAsBoolean": null,
"ValueAsNumber": null,
"ValueAsDecimal": null,
"ValueAsDate": null,
"ReferenceObject": null
},
"ReferenceObject": null
},
{
"FieldId": 76,
"ObjectId": 3,
"DataTypeId": 10,
"DataTypeName": "Reference",
"Label": "Custodian",
"IsRequired": false,
"Position": 1,
"Guid": 8744623462400,
"IsSystemField": false,
"IsReferenceValue": false,
"DefaultValue": null,
"CopyPreviousValueOnSaveAndNew": false,
"Value": {
"ObjectFieldValueId": 2182,
"ObjectFieldId": 76,
"ObjectId": 3,
"PrimaryKeyId": 57,
"ValueAsString": null,
"ValueAsBoolean": null,
"ValueAsNumber": null,
"ValueAsDecimal": null,
"ValueAsDate": null,
"ReferenceObject": {
"ObjectFieldReferenceObjectInstanceId": 328,
"ObjectFieldValueId": 2182,
"ObjectId": 14,
"Object": null,
"PrimaryObjectId": 3,
"PrimaryKeyId": 57,
"KeyType": "Int32",
"DisplayFormat": "%Name%",
"IsSystemObject": false,
"Name": null,
"NumberOfValues": 1,
"Values": [
{
"ObjectFieldReferenceObjectInstanceValueId": 247,
"ObjectFieldReferenceObjectInstanceId": 328,
"KeyAsString": null,
"KeyAsInteger": 6,
"KeyAsLong": null,
"Value": "Albert Lloyd"
}
]
}
},
"ReferenceObject": null
}
],
"CreatedByFullName": "Max Miller",
"CreatedById": "25a34a2f-e3d8-4690-88f5-6b399cf88c4c",
"CreatedOn": "2024-04-18T11:53:25.6034461+00:00",
"CreatedBy": null,
"LastUpdatedByFullName": "Max Miller",
"LastUpdatedById": "25a34a2f-e3d8-4690-88f5-6b399cf88c4c",
"LastUpdatedOn": "2024-04-18T12:03:26.1849425+00:00",
"LastUpdatedBy": null
}