none
PickList - Server was unable to process request. RRS feed

  • Pergunta

  • Bom dia...

    Sou novo no CRM, estou utilizando o CRM 4.0 e estou tentando criar uma opção em um pickList, estou usando o seguinte código descrito abaixo, o problema é que da o seguinte erro:

    Server was unable to process request.

    Nessa linha:

    InsertOptionValueResponse

     

    insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);



    o codigo que utilizo:

    CrmAuthenticationToken1

     

    token = new CrmAuthenticationToken1();
    token.AuthenticationType = 0;
    token.OrganizationName =
    "FDA";
    MetadataService metadata = new MetadataService();
    metadata.CrmAuthenticationToken = token;
    metadata.Credentials = System.Net.
    CredentialCache.DefaultCredentials;

     

     

    CrmLabel1 newCrmLabel = new CrmLabel1();
    CrmNumber langCode = new CrmNumber();
    LocLabel englishLabel = new LocLabel();

     

    langCode.Value = 1033;

    englishLabel.LanguageCode = langCode;

    englishLabel.Label =

    "New Picklist Label";

    newCrmLabel.LocLabels =

    new LocLabel[] { englishLabel };

     

    InsertOptionValueRequest insertRequest = new InsertOptionValueRequest();

     

    insertRequest.AttributeLogicalName = "un_estado_civil";

    insertRequest.EntityLogicalName =

    EntityName.contact.ToString();

    insertRequest.Label = newCrmLabel;

    insertRequest.Value =

    new CrmNumber();

     

    insertRequest.Value.Value = 200003;

     

    InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);

     

    CrmAuthenticationToken toke = new CrmAuthenticationToken();

    toke.AuthenticationType = 0;

    toke.OrganizationName =

    "FDA";

     

    CrmService crmservice = new CrmService();

     

    crmservice.CrmAuthenticationTokenValue = toke;

    crmservice.Credentials = System.Net.

    CredentialCache.DefaultCredentials;

     

     

    PublishAllXmlRequest publishAllRequest = new PublishAllXmlRequest();

     

    PublishAllXmlResponse publishAllResponse = (PublishAllXmlResponse)crmservice.Execute(publishAllRequest);

    segunda-feira, 13 de abril de 2009 14:57

Respostas

  • Ola Gilberto...

    Obrigado!!!

    Consegui descobrir onde estava o problema...

    Mudei essas partes:

    langCode.Value = 1046;

    e

    insertRequest.Value.formattedvalue =

    "6";

    Segue o codigo completo:

     

    CrmAuthenticationToken1 token = new CrmAuthenticationToken1();
    token.AuthenticationType = 0;
    token.OrganizationName =
    "FDA";
    MetadataService metadata = new MetadataService();

     

    metadata.CrmAuthenticationToken = token;
    metadata.Credentials = System.Net.
    CredentialCache.DefaultCredentials; 

     

    CrmLabel1 newCrmLabel = new CrmLabel1();
    CrmNumber langCode = new CrmNumber();
    LocLabel englishLabel = new LocLabel();
    langCode.Value = 1046;
    englishLabel.LanguageCode = langCode;
    englishLabel.Label =
    "teste2";
    newCrmLabel.LocLabels =
    new LocLabel[] { englishLabel};

     

    InsertOptionValueRequest insertRequest = new InsertOptionValueRequest();
    insertRequest.AttributeLogicalName = "un_estado_civil";
    insertRequest.EntityLogicalName =
    EntityName.contact.ToString();
    insertRequest.Label = newCrmLabel;
    insertRequest.Value =
    new CrmNumber();
    insertRequest.Value.Value = 6;
    insertRequest.Value.formattedvalue =
    "6";

     

    InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);

     

    CrmAuthenticationToken toke = new CrmAuthenticationToken();
    toke.AuthenticationType = 0;
    toke.OrganizationName =
    "FDA";
    CrmService crmservice = new CrmService();
    crmservice.CrmAuthenticationTokenValue = toke;
    crmservice.Credentials = System.Net.
    CredentialCache.DefaultCredentials;
    PublishAllXmlRequest publishAllRequest = new PublishAllXmlRequest();
    PublishAllXmlResponse publishAllResponse = (PublishAllXmlResponse)crmservice.Execute(publishAllRequest);



    • Marcado como Resposta Rafael.Moreno quarta-feira, 15 de abril de 2009 10:49
    quarta-feira, 15 de abril de 2009 10:46

Todas as Respostas

  • Rafasax,

    Adicione um try/catch na linha que ocorre o erro para obter o erro detalhado, da seguinte forma:


    Substitua:

       InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);

    por

       InsertOptionValueResponse insertResponse = null;
       try
       {
        insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);
       }
       catch(System.Web.Services.Protocols.SoapException ex)
       {
        string x = ex.Detail.InnerText;
       }


    []

    Gilberto Tezini - MCP ASP.NET (C#/VB.NET) / MCP CRM - (http://gtezini.blogspot.com)
    terça-feira, 14 de abril de 2009 15:25
  • Ola Gilberto...

    Obrigado!!!

    Consegui descobrir onde estava o problema...

    Mudei essas partes:

    langCode.Value = 1046;

    e

    insertRequest.Value.formattedvalue =

    "6";

    Segue o codigo completo:

     

    CrmAuthenticationToken1 token = new CrmAuthenticationToken1();
    token.AuthenticationType = 0;
    token.OrganizationName =
    "FDA";
    MetadataService metadata = new MetadataService();

     

    metadata.CrmAuthenticationToken = token;
    metadata.Credentials = System.Net.
    CredentialCache.DefaultCredentials; 

     

    CrmLabel1 newCrmLabel = new CrmLabel1();
    CrmNumber langCode = new CrmNumber();
    LocLabel englishLabel = new LocLabel();
    langCode.Value = 1046;
    englishLabel.LanguageCode = langCode;
    englishLabel.Label =
    "teste2";
    newCrmLabel.LocLabels =
    new LocLabel[] { englishLabel};

     

    InsertOptionValueRequest insertRequest = new InsertOptionValueRequest();
    insertRequest.AttributeLogicalName = "un_estado_civil";
    insertRequest.EntityLogicalName =
    EntityName.contact.ToString();
    insertRequest.Label = newCrmLabel;
    insertRequest.Value =
    new CrmNumber();
    insertRequest.Value.Value = 6;
    insertRequest.Value.formattedvalue =
    "6";

     

    InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);

     

    CrmAuthenticationToken toke = new CrmAuthenticationToken();
    toke.AuthenticationType = 0;
    toke.OrganizationName =
    "FDA";
    CrmService crmservice = new CrmService();
    crmservice.CrmAuthenticationTokenValue = toke;
    crmservice.Credentials = System.Net.
    CredentialCache.DefaultCredentials;
    PublishAllXmlRequest publishAllRequest = new PublishAllXmlRequest();
    PublishAllXmlResponse publishAllResponse = (PublishAllXmlResponse)crmservice.Execute(publishAllRequest);



    • Marcado como Resposta Rafael.Moreno quarta-feira, 15 de abril de 2009 10:49
    quarta-feira, 15 de abril de 2009 10:46
  • Ola Gilberto...

    Obrigado!!!

    Consegui descobrir onde estava o problema...

    Mudei essas partes:

    langCode.Value = 1046;

    e

    insertRequest.Value.formattedvalue =

     

    "6";

    Segue o codigo completo:

     

    CrmAuthenticationToken1 token = new CrmAuthenticationToken1();
    token.AuthenticationType = 0;
    token.OrganizationName =
    "FDA";
    MetadataService metadata = new MetadataService();

     

     

    metadata.CrmAuthenticationToken = token;
    metadata.Credentials = System.Net.
    CredentialCache.DefaultCredentials; 

     

     

    CrmLabel1 newCrmLabel = new CrmLabel1();
    CrmNumber langCode = new CrmNumber();
    LocLabel englishLabel = new LocLabel();
    langCode.Value = 1046;
    englishLabel.LanguageCode = langCode;
    englishLabel.Label =
    "teste2";
    newCrmLabel.LocLabels =
    new LocLabel[] { englishLabel};

     

     

    InsertOptionValueRequest insertRequest = new InsertOptionValueRequest();
    insertRequest.AttributeLogicalName = "un_estado_civil";
    insertRequest.EntityLogicalName =
    EntityName.contact.ToString();
    insertRequest.Label = newCrmLabel;
    insertRequest.Value =
    new CrmNumber();
    insertRequest.Value.Value = 6;
    insertRequest.Value.formattedvalue =
    "6";

     

     

    InsertOptionValueResponse insertResponse = (InsertOptionValueResponse)metadata.Execute(insertRequest);

     

    CrmAuthenticationToken toke = new CrmAuthenticationToken();
    toke.AuthenticationType = 0;
    toke.OrganizationName =
    "FDA";
    CrmService crmservice = new CrmService();
    crmservice.CrmAuthenticationTokenValue = toke;
    crmservice.Credentials = System.Net.
    CredentialCache.DefaultCredentials;
    PublishAllXmlRequest publishAllRequest = new PublishAllXmlRequest();
    PublishAllXmlResponse publishAllResponse = (PublishAllXmlResponse)crmservice.Execute(publishAllRequest);



     


    Qual a diferenca de colocar

    langCode.Value = 1046; ou langCode.Value = 1033;???

    e

    para que serve o formattedvalue ?? (exemplo: insertRequest.Value.formattedvalue = "6";)



    Obrigado!!!

    quarta-feira, 15 de abril de 2009 10:48
  • LanguageCode - Obrigatório informar qual o código do idioma do produto (1033 para Inglês, 1046 para Português, etc);

    formattedvalue - não é obrigatório; use qdo desejar mostrar a informação formatada. Por exemplo, para um campo de valor, pode usar: formattedvalue  = "$123.00";

    Gilberto Tezini - MCP ASP.NET (C#/VB.NET) / MCP CRM - (http://gtezini.blogspot.com)
    quarta-feira, 15 de abril de 2009 16:44