custom workflow in ms crm Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/custom-workflow-in-ms-crm/ Microsoft Dynamics CRM . Microsoft Power Platform Thu, 09 Jul 2020 16:47:33 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 custom workflow in ms crm Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/custom-workflow-in-ms-crm/ 32 32 176351444 Error : The property is of type EntityReference but doesn’t contain the ReferenceTarget attribute http://microsoftdynamics.in/2020/07/09/error-the-property-is-of-type-entityreference-but-doesnt-contain-the-referencetarget-attribute/ Thu, 09 Jul 2020 16:47:33 +0000 http://microsoftdynamics.in/?p=3879 While registering a custom Workflow Activity we can get below error if we are missing Reference Target entity

The property lookup from Configration Entity is of type EntityReference but doesn't contain the ReferenceTarget attribute

Code with missing reference Target or Code with Error

The post Error : The property <name> is of type EntityReference but doesn’t contain the ReferenceTarget attribute appeared first on Microsoft Dynamics 365 Blog.

]]>

If we are getting below error while registering a custom Workflow

The property from is of type EntityReference but doesn't contain the ReferenceTarget attribute

Then we are missing Reference Target Parameter

While registering a custom Workflow Activity we can get below error if we are missing Reference Target entity

The property lookup from Configration Entity is of type EntityReference but doesn’t contain the ReferenceTarget attribute

  • Code with missing reference Target or Code with Error

  using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Workflow;
    using System.Activities;
    using Microsoft.Xrm.Sdk.Query;

    public class ViolationCreateOppProductandSalesOrde : CodeActivity
    {
    
        #region InputParameter
        /// <summary>
        /// Opportunity LookUp as an input parameter
        /// </summary>
        [RequiredArgument]
        [Input("Lookup Schema Name")]
        public InArgument<EntityReference> Configration{ get; set; }

------------------------------
---------
-------------------------------
  • Code Corrected and Added Reference Target ( Tat will contain Target entity name)
  using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Workflow;
    using System.Activities;
    using Microsoft.Xrm.Sdk.Query;

    public class ViolationCreateOppProductandSalesOrde : CodeActivity
    {
    
        #region InputParameter
        /// <summary>
        /// Opportunity LookUp as an input parameter
        /// </summary>
        [RequiredArgument]
        [Input("LookUP")]
        [ReferenceTarget("opportunity")]
        public InArgument<EntityReference> Configration { get; set; }

------------------------------
---------
-------------------------------

Hope this was Help Full.

Thanks

The post Error : The property <name> is of type EntityReference but doesn’t contain the ReferenceTarget attribute appeared first on Microsoft Dynamics 365 Blog.

]]>
3879
Share A Record With Read Only Access Using Custom Workflow IN MS CRM 2011 , MS CRM 2013 , MS CRM 2015 http://microsoftdynamics.in/2015/01/05/share-a-record-with-read-only-access-using-custom-workflow-in-ms-crm-2011-ms-crm-2013-ms-crm-2015/ Sun, 04 Jan 2015 20:00:00 +0000 http://microsoftdynamics.in/2015/01/05/share-a-record-with-read-only-access-using-custom-workflow-in-ms-crm-2011-ms-crm-2013-ms-crm-2015/ Share a Record to a user without Assigning the record and with out giving Read access to that user , its a Custom Workflow to share a record with read only access , ( NOTE : You can not give read only access to owner of that record so , first we have to change...

The post Share A Record With Read Only Access Using Custom Workflow IN MS CRM 2011 , MS CRM 2013 , MS CRM 2015 appeared first on Microsoft Dynamics 365 Blog.

]]>
Share a Record to a user without Assigning the record and with out giving Read access to that user , its a Custom Workflow to share a record with read only access , ( NOTE : You can not give read only access to owner of that record so , first we have to change the owner and then we can share it to created by user with read only access )


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Portal;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Workflow;
using System.Activities;
using Microsoft.Crm.Sdk.Messages;


namespace Readonlyaccess_sharerecord
{
    public class Class1 : CodeActivity
    {
        #region input parameter
        // In set property : give the user to whom record will be shared
        [ Input( “User_to_Share” )]
        // look up field of system user “Entity Name”
        [ ReferenceTarget (“systemuser” )]
        public InArgument <EntityReference > _User_to_Share { getset; }
        #endregion

        #region Output parameter
        //
        [ Output( “condition” )]
        public OutArgument <string > _condition { getset; }

        #endregion
        protected override void Execute( CodeActivityContext context)
        {

            IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext >();
            IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory >();
            IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);
            #region paramters
            EntityReference User_to_Share = _User_to_Share.Get<EntityReference >(context);

            #endregion
            try
            {
                Entity Obj_entity = (Entity )service.Retrieve(workflowContext.PrimaryEntityName, workflowContext.PrimaryEntityId, newColumnSet (true ));

                try
                {
                    //no delete access
                    GrantAccessRequest grant = new GrantAccessRequest ();
                    grant.Target = new EntityReference (workflowContext.PrimaryEntityName, workflowContext.PrimaryEntityId);

                    PrincipalAccess principal = new PrincipalAccess ();
                    principal.Principal = User_to_Share;
                    principal.AccessMask = AccessRights .ReadAccess;
                    grant.PrincipalAccess = principal;
                    GrantAccessResponse grant_response = (GrantAccessResponse )service.Execute(grant);
                    _condition.Set(context, “1” );

                }
                catch ( Exception ex)
                {
                    _condition.Set(context, “0” );
                    throw new Exception( “Enable to Grant Read Access i.e.” + ex.Message);
                }

            }
            catch ( Exception ex)
            {
                throw new Exception( “Error Due To Master User Share i.e.” + ex.Message);
            }

        }
    }
}

1. Add Step to your Workflow.

2. Set Property and provide the user whom to share the record.

3. Forms become readonly after execution of record

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

The post Share A Record With Read Only Access Using Custom Workflow IN MS CRM 2011 , MS CRM 2013 , MS CRM 2015 appeared first on Microsoft Dynamics 365 Blog.

]]>
2805