how to create fax activity programatically?

Answered how to create fax activity programatically?

  • 2007년 11월 28일 수요일 오전 10:30
     
     

    Hi all,

     

    Please explain or give me link of any helpful material where I can learn how to create fax activity, I just need to make a record of fax activity I wont be sending any fax...

     

    thanks

모든 응답

  • 2007년 11월 28일 수요일 오후 5:48
    소유자
     
     답변됨

     

    Hi Hassanz,

     

    Have a look SDK about 'Create'

     

    Here's an example:

     

    Code Block

    CrmService service = new CrmService();

    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

     

    fax f = new fax();

    f.activityid = new Key();

    f.activityid.Value = aGuid;

    f.subject = "Hello";

    service.Update(f);

     

     

     

    Cheers,
    Jim

  • 2007년 11월 29일 목요일 오전 8:08
     
     
    In SDK:

    // Set up the CRM Service.
     CrmService service = new CrmService();
     service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    // Get the current user.
     WhoAmIRequest userRequest = new WhoAmIRequest();
     WhoAmIResponse user = (WhoAmIResponse)
     service.Execute(userRequest);
     // Create the fax object.
    fax fax = new fax();
    // Set the properties of the fax.
    fax.subject = "Test Fax";
    fax.description = "New Fax";
    // Create the party sending and receiving the fax.
    activityparty party = new activityparty();
    // Set the properties of Activityparty.
    party.partyid = new Lookup();
    party.partyid.type = EntityName.systemuser.ToString();
    party.partyid.Value = user.UserId;
    // The party sends and receives the fax.
    fax.from = new activityparty[] {party};
    fax.to = new activityparty[] {party};
    // Create the fax.
    Guid createdFaxId = service.Create(fax);

    I copy this code to my project.It returns this error when running:
    "Server was unable to process request."
  • 2007년 11월 30일 금요일 오전 5:33
     
     

    Does the thrown exception give any more detailed information?

  • 2007년 11월 30일 금요일 오전 8:50
     
     
    Server was unable to process request.. 0x80040237 Operation failed due to a SQL integrity violation. Platform
  • 2007년 11월 30일 금요일 오전 10:41
    소유자
     
     

    Hi Jeck,

     

    Make sure that your CRM webservice url is current.

    Also, try debug it or use try{} catch{} to get more information.

     

    Regards,

    Jim

  • 2007년 11월 30일 금요일 오전 11:39
    중재자
     
     

    The problem may be to do with the way you pas the same party to the to and from properties. Try creating separate instances of the activityparty class for each of them.

     

    Otherwise I'd try using either SQL profiler, or CRM tracing to identify the SQL statement that causes the error and work from that (I'm guessing that duplicate activitypartyid values are being sent)

  • 2007년 12월 1일 토요일 오전 12:23
     
     
    I created separate instances of the activityparty class for each of them. The same error returned.   
    Then I removed the web service reference and re-add it,also returned the same error. (0x80040237 Operation failed due to a SQL integrity violation. Platform )       
                    try
                    { 
                    // Set up the CRM Service.
                    CrmService service = new CrmService();
                    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    // Get the current user.
                    WhoAmIRequest userRequest = new WhoAmIRequest();
                    WhoAmIResponse user = (WhoAmIResponse)service.Execute(userRequest);

                    // Create the fax object.
                    fax fax = new fax();

                    // Set the properties of the fax.
                    fax.subject = "Test Fax";
                    fax.description = "New Fax";

                    // Create the party sending and receiving the fax.
                    activityparty party1 = new activityparty();

                    // Set the properties of Activityparty.
                    party1.partyid = new Lookup();
                    party1.partyid.type = EntityName.systemuser.ToString();
                    party1.partyid.Value = user.UserId;

                    // The party sends and receives the fax.
                    fax.from = new activityparty[] { party1 };

                    // Create the party sending and receiving the fax.
                    activityparty party2 = new activityparty();

                    // Set the properties of Activityparty.
                    party2.partyid = new Lookup();
                    party2.partyid.type = EntityName.systemuser.ToString();
                    party2.partyid.Value = user.UserId;

                    fax.to = new activityparty[] { party2 };

                    // Create the fax.
                    Guid createdFaxId = service.Create(fax);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    lbl1.Text = ex.Message + "." + ex.Detail.InnerText;
                }
  • 2007년 12월 1일 토요일 오전 12:41
     
     
    Hi,Jim! Thanks for your help! You are so smart and kind!
    Well,David and Greg are as nice as Jim!
  • 2007년 12월 1일 토요일 오전 1:33
     
     

     

    Hmm, Something else is going on here.  I tested both of your samples in an winform application of mine and both create the fax activity.

     

    Is this code running in a web application or a winform perhaps the user does not have the proper rights or is not a system user?

     

    http://www.ureader.com/message/3397436.aspx

    http://blogs.infinite-x.net/2007/04/26/error-0x80040237-operation-failed-due-to-a-sql-integrity-violation/print/

     

     

  • 2007년 12월 1일 토요일 오전 2:18
     
     
    Thank you Greg! My code is running in a web application.
    I do it as you said,and now I can create a fax intance.
    It's very nice of you! Thank you again!