Parents
  • Raising this request again. The reason we need these API is because (in UIX v1) they also work for users with read-only license. The usual workaround to checkout the object, manipulate the properties and check back in would not work for read-only users.

  • This can already be done using SetPropertiesMultiple. Works also for read-only users as no check-out/in is required -- just make sure you only try to set the assignment properties they can change.

    Here is an example of marking an object completed. It assumes the object is assigned to only the current user. Proper implementations would need to verify that, and also handle cases where multiple people are assigned -- modifying existing property values instead of blindly overwriting them. Also property error handling, etc...


    /**
     * Marks the passed object as complete
     * @param {IVault} vault
     * @param {ObjectVersionEx} objVerEx
     */
    async function markCompletedByCurrentUser( vault, objVerEx ) {
    
        // Resolve current user.
    	const sessionInfo = await MFiles.GetSessionInfo();
    	const userId = sessionInfo.vault_data.user_id;
    	
    	// TODO: Verify object is assigned to current user.
    
        // Update object adding the current user to the "Marked as complete by" property,
        // and removing them from the "Assigned to" property.
    	await vault.ObjectOperations.SetPropertiesMultiple( {
    		properties: [
    			{
    				obj_ver: {
    					obj_id: objVerEx.object_info.obj_id,
    					version: objVerEx.version_info.version
    				},
    				allow_modifying_checked_in_object: true,
    				fail_if_not_latest_checked_in_version: true,
    				object_version_guid: "{00000000-0000-0000-0000-000000000000}",
    				set_properties: [
    					{
    						property_def: 44,  // Assigned to
    						value: {
    							type: 10,  // Multi-select lookup
    							is_null_value: true,
    							data: {
    								multi_select_lookup: {
    									values: []
    								}
    							}
    						}
    					},
    					{
    						property_def: 45,  // Marked as complete by
    						value: {
    							type: 10,  // Multi-select lookup
    							is_null_value: false,
    							data: {
    								multi_select_lookup: {
    									values: [
    										{
    											value_list_item_info: {
    												obj_id: {
    													type: 6, // User list
    													item_id: {
    														internal_id: userId,  // Current user id
    														external_repository_id: {
    															connection: "",
    															item: ""
    														}
    													}
    												},
    												external_id_status: 0,
    												guid: "{00000000-0000-0000-0000-000000000000}",
    												options: {},
    											},
    											version: {
    												type: 1,
    												internal_version: -1,
    												external_repository_version: "",
    												external_repository_sort_key: 0
    											}
    										}
    									]
    								}
    							}
    						}
    					}
    				],
    				is_full_set: false,
    				remove_properties: []
    			}
    		]
    	} );
    }




Reply
  • This can already be done using SetPropertiesMultiple. Works also for read-only users as no check-out/in is required -- just make sure you only try to set the assignment properties they can change.

    Here is an example of marking an object completed. It assumes the object is assigned to only the current user. Proper implementations would need to verify that, and also handle cases where multiple people are assigned -- modifying existing property values instead of blindly overwriting them. Also property error handling, etc...


    /**
     * Marks the passed object as complete
     * @param {IVault} vault
     * @param {ObjectVersionEx} objVerEx
     */
    async function markCompletedByCurrentUser( vault, objVerEx ) {
    
        // Resolve current user.
    	const sessionInfo = await MFiles.GetSessionInfo();
    	const userId = sessionInfo.vault_data.user_id;
    	
    	// TODO: Verify object is assigned to current user.
    
        // Update object adding the current user to the "Marked as complete by" property,
        // and removing them from the "Assigned to" property.
    	await vault.ObjectOperations.SetPropertiesMultiple( {
    		properties: [
    			{
    				obj_ver: {
    					obj_id: objVerEx.object_info.obj_id,
    					version: objVerEx.version_info.version
    				},
    				allow_modifying_checked_in_object: true,
    				fail_if_not_latest_checked_in_version: true,
    				object_version_guid: "{00000000-0000-0000-0000-000000000000}",
    				set_properties: [
    					{
    						property_def: 44,  // Assigned to
    						value: {
    							type: 10,  // Multi-select lookup
    							is_null_value: true,
    							data: {
    								multi_select_lookup: {
    									values: []
    								}
    							}
    						}
    					},
    					{
    						property_def: 45,  // Marked as complete by
    						value: {
    							type: 10,  // Multi-select lookup
    							is_null_value: false,
    							data: {
    								multi_select_lookup: {
    									values: [
    										{
    											value_list_item_info: {
    												obj_id: {
    													type: 6, // User list
    													item_id: {
    														internal_id: userId,  // Current user id
    														external_repository_id: {
    															connection: "",
    															item: ""
    														}
    													}
    												},
    												external_id_status: 0,
    												guid: "{00000000-0000-0000-0000-000000000000}",
    												options: {},
    											},
    											version: {
    												type: 1,
    												internal_version: -1,
    												external_repository_version: "",
    												external_repository_sort_key: 0
    											}
    										}
    									]
    								}
    							}
    						}
    					}
    				],
    				is_full_set: false,
    				remove_properties: []
    			}
    		]
    	} );
    }




Children