IOrganizationService Extensions


Retrieve Methods
  • WhoAmI - Performs a WhoAmI request.
    • public static WhoAmIResponse WhoAmI(this IOrganizationService service)
    • Useful for obtaining information about the caller and organization.
  • RetrieveAttributeMetadata - Retrieves attribute metadata for the specified entity and attribute.
    • public static AttributeMetadata RetrieveAttributeMetadata(this IOrganizationService service, string entityName, string attributeName)
  • RetrieveRecordDetails - Retrieves details about a record and its attributes and formats them in a listed String format.
    • public static String RetrieveRecordDetails(this IOrganizationService service, String entityName, Guid recordId)
    • Useful for obtaining information about a record and printing it to the Console or log.
  • RetrieveEntityDetails - Retrieves details from entity metadata and formats it in a listed String format.
    • public static String RetrieveEntityDetails(this IOrganizationService service, String entityName)
    • Useful for obtaining information about an entity and printing it to the Console or log.
  • RetrieveRecordIds - Retrieves the record ids (GUIDs) that match the set of constraints.
    • public static IEnumerable<Guid> RetrieveRecordIds(this IOrganizationService service, String entityName, IEnumerable<KeyValuePair<String, Object>> constraints)
    • Useful as a lightweight call to grab all of the matching record id's from CRM if other columns are not needed.
  • RetrieveOptionSetDisplayValue - Retrieves the option set display value based on the specified integer value.
    • public static String RetrieveOptionSetDisplayValue(this IOrganizationService service, String entityName, String attributeName, Int32 optionSetIntegerValue)
  • RetrieveOptionSetIntegerValue - Retrieves the option set integer value based on the specified display value.
    • public static Int32 RetrieveOptionSetIntegerValue(this IOrganizationService service, String entityName, String attributeName, String optionSetDisplayValue)
  • RetrieveUserFromId - Retrieves the user entity from its id.
    • public static Entity RetrieveUserFromId(this IOrganizationService service, Guid id)
  • RetrieveUserFromInternalEmailAddress - Retrieves the user entity with matching internal email address. If multiple are found, the first will be returned.
    • public static Entity RetrieveUserFromInternalEmailAddress(this IOrganizationService service, String internalEmailAddress)
  • RetrieveUserFullNameFromId - Retrieves the users full name based on the specified user id (GUID).
    • public static String RetrieveUserFullNameFromId(this IOrganizationService service, Guid id)
    • Useful for quickly getting the users full name when the user ID is known.
  • RetrieveCallerFullName - Retrieves the full name of the caller running the application.
    • public static String RetrieveCallerFullName(this IOrganizationService service)
  • RetrieveAttributeValue - Retrieves an attribute value using specified entity name, attribute name, and record id.
    • public static T RetrieveAttributeValue<T>(this IOrganizationService service, String entityName, String attributeName, Guid id)
  • RetrieveRecords - Retrieves records for a specific entity with overloads to allow data retrieval for multiple conditions.
    • public static IEnumerable<Entity> RetrieveRecords(this IOrganizationService service, String entityName, String attributeNameToCompare = null, Object attributeValueToCompare = null, ColumnSet columns = null)
      • Retrieves records for a specific entity with optional filter parameters for comparing an attribute with a value and ability to return a subset of columns. The default setting is to return all columns.
    • public static IEnumerable<Entity> RetrieveRecords<T>(this IOrganizationService service, String entityName, String attributeNameToCompare, IEnumerable<T> attributeValuesToCompare, LogicalOperator filterOperator, ColumnSet columns = null)
      • Retrieves records for a specific entity with the ability to specify an array of values to match for a specific entity. The filterOperator parameter should be specified to "AND" or "OR" these values. The default is to return all columns.
  • RetrieveRecordsExcept - Retrieves all records except those that match the criteria specified. An attribute must be given as well as an array of values that must not match this attribute. An optional FilterParameter and ColumnSet may be passed in. The default is to AND all values and to return all columns.
    • public static IEnumerable<Entity> RetrieveRecordsExcept<T>(this IOrganizationService service, String entityName, String attributeNameToCompare, IEnumerable<T> attributeValuesToCompare, LogicalOperator filterOperator = LogicalOperator.And, ColumnSet columns = null)
  • RetrieveRecordsForManyToManyRelatedIds - Retrieves records for an entity with a many-to-many relationship that are related to a specific record ID on the related entity.
    • public static IEnumerable<Entity> RetrieveRecordsForManyToManyRelatedId(this IOrganizationService service, String primaryEntityName, String intersectTableName, String primaryAttributeIdName, String relatedAttributeIdName, Guid relatedAttributeIdValue, ColumnSet columns = null)
    • Useful for retrieving records that are related to a record in a N:N relationship. To use this you must know the name of the intersect table (found on the N:N relationship).
  • RetrieveAttributeValue - Retrieves the attribute value using specified criteria. Multiple overloads exist depending on available information.
    • public static T RetrieveAttributeValue<T>(this IOrganizationService service, String entityName, String attributeName, Guid id)
      • Retrieves the attribute value using specified entity name, attribute name, and record id.
    • public static T RetrieveAttributeValue<T>(this IOrganizationService service, String entityName, String attributeNameToRetrieve, String attributeNameToCompare, Object attributeValueToCompare)
      • Retrieves the attribute value for specified criteria. If zero or multiple records are found, an XrmLibraryException will be thrown.
  • RetrieveAttributeValues - Retrieves a set of attribute values for all records that match specified criteria.
    • public static IEnumerable<T> RetrieveAttributeValues<T>(this IOrganizationService service, String entityName, String attributeNameToRetrieve, String attributeNameToCompare = null, Object attributeValueToCompare = null)
  • RetrieveRecordCount - Retrieves the record count for a specific entity. Overloads are available for passing criteria.
    • public static Int32 RetrieveRecordCount(this IOrganizationService service, String entityName)
      • Gets the record count for a specific entity. The maximum record count for a retrieve multiple is 5000 records.
    • public static Int32 RetrieveRecordCount(this IOrganizationService service, String entityName, String attributeNameToCompare, object attributeValueToCompare)
      • Retrieves the record count with a filter. The maximum record count for a retrieve multiple is 5000 records.
  • RetrieveAllRolesForUser - Retrieves all roles related to a specified user record.
    • public static IEnumerable<Entity> RetrieveAllRolesForUser(this IOrganizationService service, Entity user)
  • RetrieveRoleByName - Retrieves a role record based on its name and business unit. If the business unit is not specified, it will not be used as a filter.
    • public static Entity RetrieveRoleByName(this IOrganizationService service, String roleStr, Guid? businessUnitId = null)
  • RetrieveRoleFromUser - Retrieves a role record based on specified user and role name.
    • public static Entity RetrieveRoleFromUser(this IOrganizationService service, Entity user, String roleName)
  • RetrieveBusinessUnitFromName - Retrieves a business unit record using the specified business unit name.
    • public static Entity RetrieveBusinessUnitFromName(this IOrganizationService service, String businessUnitName)
  • RetrieveBusinessUnitFromId - Retrieves a business unit record using the specified business unit ID (GUID).
    • public static Entity RetrieveBusinessUnitFromId(this IOrganizationService service, Guid businessUnitId)
  • RetrieveAllUsersBelongingToTeam - Retrieves all the users belonging to specified team ID (GUID).
    • public static IEnumerable<Entity> RetrieveAllUsersBelongingToTeam(this IOrganizationService service, Guid teamId)
    • Useful for finding all members of a team.

Create Methods
  • CreateRecord - Creates a record using the entity name and set of key value pairs.
    • public static Guid CreateRecord(this IOrganizationService service, String entityName, IEnumerable<KeyValuePair<String, Object>> attributes)
    • Useful for creating a record inline using a set of KeyValuePairs.

Update Methods
  • UpdateAttributeValues - Updates all entities matching constraints with a specific value for a single attribute. Useful for updating a value across one or more records.
    • public static Int32 UpdateAttributeValues(this IOrganizationService service, String entityName, String attributeNameToUpdate, Object attributeValue, String attributeNameToCompare = null, Object attributeValueToCompare = null)
  • SetUserOrTeamsBusinessUnit - Sets the user or teams business unit. Multiple overloads are available depending on criteria available.
    • public static void SetUserOrTeamsBusinessUnit(this IOrganizationService service, Entity userOrTeam, String businessUnitName)
      • Sets the user or teams business unit using the specified business unit name.
    • public static void SetUserOrTeamsBusinessUnit(this IOrganizationService service, Entity userOrTeam, Guid businessUnitId)
      • Sets the user or teams business unit using the specified business unit ID (GUID).

Associate Methods
  • AddRoleToUser - Adds a role record to a specified user.
    • public static void AddRoleToUser(this IOrganizationService service, Guid userId, Entity role)

Dissociate Methods
  • RemoveRoleFromUser - Removes a role from a specified user.
    • public static void RemoveRoleFromUser(this IOrganizationService service, Guid userId, Entity role)

Last edited Nov 8, 2011 at 6:26 PM by cchamberlain, version 4

Comments

No comments yet.