locked
Renaming the file attached RRS feed

  • Question

  • Dear Friends

    I am very new to MS-CRM 2011, I have a requirement where in , the file that gets attached inside crm should be renamed with certain "name". Is this customization possible or can be achieved.

    With Regards

    Athul MT

     

     

     


    • Edited by Athul MT Monday, October 24, 2011 6:44 AM
    Monday, October 24, 2011 6:43 AM

Answers

All replies

  • You can do it using SDK, for files there is entity in CRM called annotation and it as property called filename

    HTH


    MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview | CRM2011 Lookup Attribute Mapping
    Monday, October 24, 2011 7:29 AM
  • Hi,

    If the file will be attached inside Dynamics CRM (not SharePoint document lists) then it can be renamed via code by retrieveing the annotation entity object via GUID or ID and then changing the filename attribute value (http://msdn.microsoft.com/en-us/library/gg334587.aspx) and updating the entity record. You may also refer the sample code for Annotation attachments in the following links: http://msdn.microsoft.com/en-us/library/dd548518.aspx


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Monday, October 24, 2011 7:53 AM
    • Marked as answer by Athul MT Monday, October 24, 2011 11:01 AM
    Monday, October 24, 2011 7:52 AM
  • Dear Jehanzeb Javeed & MaKeer

            Thanks a lot for your replies

    With Regards

     

    Athul MT

     

     

     

    Monday, October 24, 2011 8:39 AM
  • Hi Athulmt,

    If you have found the reply helpful in finding the solution then pelase make sure to mark as answer.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, October 24, 2011 8:41 AM
  • Dear Jehanzeb Javeed

          I have tried the code that's mentioned in that link  and i am getting lot of error and i could not resolve that error please help me to resolve these errors i have added the reference  microsoft.xrm.sdk; 

    i couldn't even able to declare the annotation entity object

     

    Please help me to resolve this

    Thanking you.....

     



    With Regards Athul MT

    • Edited by Athul MT Wednesday, November 2, 2011 6:21 AM
    Wednesday, November 2, 2011 6:20 AM
  • You do not have EntityProxyClasses included in you project so you wont be getting Annotation object.

    If you are planning to use late bound classes following code should work. I am not sure which Plug-in event you are chaing file name. But followng code assumes that you are doing it on PostCreation.

                IOrganizationServiceFactory factory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = factory.CreateOrganizationService(context.UserId);
    
                Entity entity = (Entity)context.InputParameters["Target"];
    
                entity["name"] = "<<NEW FILE NAME>>";
    
                service.Update(entity);
    

    HTH


    MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview | CRM2011 Lookup Attribute Mapping | CRM2011 TreeView Control (Beta)
    • Proposed as answer by Philippe LEAL Wednesday, November 2, 2011 11:26 AM
    Wednesday, November 2, 2011 6:31 AM
  • Dear MaKeer

       Can you just show me a example code to retrieve data using  plugin from the current record which is created

         i have registered this plugin has post synchronous  event in create  message..

     

    Please help me...

     

     


    With Regards Athul MT
    Wednesday, November 2, 2011 11:35 AM
  • Hi,

    You can get the data of the current created record using the following code:

    public void Execute(IServiceProvider serviceProvider) {
    

    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    if (context.InputParameters.Contains("Target") &&
                        context.InputParameters["Target"] is Entity)
    {
               // Obtain the target entity from the input parmameters.
               Entity entity = (Entity)context.InputParameters["Target"];
     
        if (entity.Contains["attribute_name"]) {
       
        string attributeValue = entity["attribute_name"];

        }
        else
               {
                //if user does not enter any value then assign default value to the attribute
                entity["attribute_name"] = "default value";
               }

    }

    }

    You may also refer: http://crmconsultancy.wordpress.com/2010/10/25/plugins-in-crm-2011/


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Thursday, November 3, 2011 7:15 AM