Copy textbox content to an other textbox

Answered Copy textbox content to an other textbox

  • 28 สิงหาคม 2551 8:09
     
     

    Hi,

     

    i want to copy the text from a textbox to an other.

     

    the source attribute is a lookup and the destination is a nvarchar.

     

    I have created a plugin, which can write text to an attribute, but i can't get the text from the lookup attribute.

    In my Code Snippet, you can see how i tried to do it.

     

    Code Snippet

    Lookup test;

    test = (Lookup) entity.Properties["productid"];

    entity.Properties.Add(new StringProperty("name", test.name));

     

     

    I have done it before in this way, with two nvarchar attributes, but in this case i doesn't work.

    If i press the save button i only get the test.value and test.type but test.name is empty (i can see it in the frontend)

     

    test.name = null

    test.type = productname

    test.value = 70c1ffac-cff5-dc11-8aba-000c29c8645f

     

    any idea?

     

    thanks a lot

ตอบทั้งหมด

  • 29 สิงหาคม 2551 8:11
    ผู้ดูแล
     
     
    How are you getting the entity ? If you access it from the Target InputParameter, then the name property does not get set - you'll need to use either a postIMage or a Retrieve message to get the name

     

  • 1 กันยายน 2551 7:07
     
     

    Thx for your reply,

     

    i have realized it with a webservice.

    I think it is not the best practice, but it works.

     

    Code Snippet

    string productid = Convert.ToString(((Lookup)entity.Properties["productid"]).Value);

    #region Query product

     

    myCrmLibrary.CrmWebService.QueryByAttribute queryProduct = new myCrmLibrary.CrmWebService.QueryByAttribute();

    queryProduct.ColumnSet = new myCrmLibrary.CrmWebService.AllColumns();

    queryProduct.EntityName = "product";

    queryProduct.Attributes = new string[] { "productid" };

    queryProduct.Values = new string[] { productid };

    #endregion Query product

    myCrmLibrary.AddProductsToBrokerContract getProduct = new AddProductsToBrokerContract();

    myCrmLibrary.CrmWebService.CrmService service = getProduct.GetService(productid);

    myCrmLibrary.CrmWebService.BusinessEntityCollection retrievedProduct = service.RetrieveMultiple(queryProduct);

    myCrmLibrary.CrmWebService.BusinessEntity beProductName = ((myCrmLibrary.CrmWebService.BusinessEntity)retrievedProduct.BusinessEntities.GetValue(0));

    if (entity.Properties.Contains("name") == true)

    {

    entity.Properties["name"] = entity.Properties["productid"].ToString();

    }

    else

    {

    string sProductName = ((myCrmLibrary.CrmWebService.product)(beProductName)).name;

    entity.Properties.Add(new StringProperty("name", sProductName));

    }

     

     

  • 1 กันยายน 2551 9:21
    ผู้ดูแล
     
     คำตอบ

    I think best practice would be to register an image (probably a postImage) on the step, and access the data via the context.PostEntityImages property.

     

    For reference I've blogged about this issue here - http://mscrmuk.blogspot.com/2008/09/plug-ins-differences-between-target-and.html

    • ทำเครื่องหมายเป็นคำตอบโดย DavidJennawayMVP, Moderator 1 พฤษภาคม 2552 19:03
    •