• Tsukasa
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
I'm not sure what to title this.

I'm creating a windows application in C# and creating tickets.
Here is my error.

"A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it.
Original Priority: data value too large: SLA - 2 - Enterprise Level and/or Practice Level Failure (max length=50)"

 
Now we don't use the default Priority field we use a custom one called Priority__c.
  • Field name: Priority__c
    Field Label: Priority
    Type is: picklist
    Length: 255
    This is a custom field.
    Can be nulled.
    Createable
    Filterable
    Updateable
    Picklist Values

This is set to 255 for length so this can't be the issue.
Our admin looked over all of the rules and couldn't find anything casuing the issue.

Here is what I'm doing in my c# app

Case salesForceCase = new Case();
salesForceCase.AccountId = accountID;
salesForceCase.ContactId = contactID;
salesForceCase.Subject = salesForceCaseData.Subject;
salesForceCase.Type = salesForceCaseData.CaseType;
salesForceCase.Product_Category__c = salesForceCaseData.Product;
salesForceCase.Product_Subcategory__c = salesForceCaseData.SubProduct;
salesForceCase.Priority__c = salesForceCaseData.SLA;

//default from
salesForceCase.Origin = "Support Console";

//default status
salesForceCase.Status = "Case Opened";

salesForceCase.Description = salesForceCaseData.Description;
salesForceCase.Subject = salesForceCaseData.Subject;

//put name and phone in other contact incase it's different then one assoc with email
//this could be if they are using someone elses email which does happen
StringBuilder fullName = new StringBuilder();
fullName.Append(salesForceCaseData.FirstName);
fullName.Append(" ");
fullName.Append(salesForceCaseData.LastName);

salesForceCase.To_Contact_not_in_SF__c = fullName.ToString();
salesForceCase.To_Contact_Phone__c = salesForceCaseData.PhoneNumber;

if (CreateBatch(salesForceCase)) { do stuff }

Here is a link to the debug log taken when I ran the application.
 
http://pastebin.com/CHWZneM2

[Case: 00129405 5007000000aHtmZ] is never created even though I don't see any errors in the log

Any help of insight would be great.

Posting this question again just going to try and reword it differently since I can't seem to find an answer.

Senario

Tables

 

Asset
AssetServices__c (linked to Asset)
....etc

 

when I have a new asset that doesn't have a sales force ID, how do I upsert the Asset and AssetServices

Here is what i'm doing in code

 

//get account and create asset
Account account = (Account)qr.records[0];
Asset asset = new Asset();

//search for account and assign asset to it
asset.AccountId = account.Id;

...assign asset details

//create services
AssetServices__c services = new AssetServices__c()

..assign stuff

..upsert

 

The problem is if the asset doesn't exist already I have no ID to assing to AssetServices__c.

I am having to do my upserts twice in a row to get my data in.

 

Any help would be great

Thanks

I'm trying to bulk upsert some data, here is the structure

 

Account *parent*
Provider__c "child of Account*

Practice__c *child of Provider__c*

I always have the account id.

 

I need to add a new provider and its practices so I have something as follows.

 

Provider__c prov = new Provider__c;
Practice__c prac = new Practice__c;

prov.Account_Name__c = accountID;
prov.Name= "value";
...etc

prac.Provider__c = prov.ID
...etc

upsert(prov)
upsert(prac)

 
As you can see prov.ID is going to be empty so it flags an error trying to do the upsert.
How to I correctly link these items and upsert them?

Thanks

Here are the 2 errors I currently have with my application and looking for some pointers.

My app searches the tickets every 60seconds

I have used the windows 7 sdk and converted the wsdl file to .cs

 

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

 

Here is the current code i'm working with

SalesForce.cs

public class SalesForce
    {
        private SforceService binding = new SforceService();

        public bool logout()
        {
            try
            {
                binding.logout();
                return true;
            }
            catch (Exception ex)
            {
                EZDebug.SendError(ex.Message, "SF Logout");
                return false;
            }
        }

        public bool login(string username, string password, string token)
        {
            binding.Timeout = 60000;

            LoginResult lr;
            try
            {
                lr = binding.login(username, password + token);
            }
            catch (SoapException ex)
            {
                EZDebug.SendError(ex.Message, "Login Error");
                return false;
            }

            if (lr.passwordExpired)
            {
                MessageBox.Show("Password Expired");
                return false;
            }

            binding.Url = lr.serverUrl;
            binding.SessionHeaderValue = new SessionHeader();
            binding.SessionHeaderValue.sessionId = lr.sessionId;
            return true;
        }

        public DataTable sfQ(string department)
        {
            DataTable ticketList = new DataTable("tickets");
            DataColumn sfstatus = new DataColumn("status", typeof(System.String));
            DataColumn sfaccountid = new DataColumn("accountid", typeof(System.String));
            DataColumn sfclientid = new DataColumn("clientid", typeof(System.String));
            DataColumn sfticketnumber = new DataColumn("ticketnumber", typeof(System.String));
            DataColumn sfsubject = new DataColumn("subject", typeof(System.String));
            DataColumn sfesc = new DataColumn("esc", typeof(System.String));
            ticketList.Columns.Add(sfstatus);
            ticketList.Columns.Add(sfaccountid);
            ticketList.Columns.Add(sfclientid);
            ticketList.Columns.Add(sfticketnumber);
            ticketList.Columns.Add(sfsubject);
            ticketList.Columns.Add(sfesc);
            ticketList.PrimaryKey = new DataColumn[] {sfticketnumber};

            string statment = "select IsEscalated, Customer_Number__c, AccountId, Subject, CaseNumber, Product_Category__c, Status from Case where Product_Category__c = '" + department + "' and (Status = 'New'or Status = 'Client Called Back' or Status = 'Client Called Back - 2nd Time!' or Status = 'Client Called Back - Escalated')";
            QueryResult qr = null;
            QueryResult qr2 = null;
            binding.QueryOptionsValue = new QueryOptions();
            binding.QueryOptionsValue.batchSize = 250;
            binding.QueryOptionsValue.batchSizeSpecified = true;
            try
            {
                qr = binding.query(statment);
                bool done = false;
                if (qr.size > 0)
                {
                    while (!done)
                    {
                        for (int i = 0; i < qr.records.Length; i++)
                        {
                            Case sfcase = (Case)qr.records[i];
                            string gbsclientid = sfcase.Customer_Number__c;
                            string stat = sfcase.Status;
                            string tn = sfcase.CaseNumber;
                            string subj = sfcase.Subject;
                            string clientid = sfcase.AccountId;
                            string esc = "";
                            esc = sfcase.IsEscalated.ToString();
                            qr2 = binding.query("select id, Name from Account where id = '" + clientid + "'");
                            Account account = (Account)qr2.records[0];
                            string accountid = account.Name;

                            ticketList.Rows.Add(stat, accountid, gbsclientid, tn, subj, esc);

                        }

                        if (qr.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qr = binding.queryMore(qr.queryLocator);
                        }
                    }
                    return ticketList;
                }
                else
                {
                    ticketList.Clear();
                    return ticketList;
                }
            }
            catch (Exception ex)
            {
                EZDebug.SendError(ex.Message, "SFQ Error");
                if (login(Global.sfUsername, Global.sfPassword, Global.sfToken))
                {
                    sfQ(Global.Department);
                }
                ticketList.Clear();
                return ticketList;
            }
        }
    }

 

Main.cs

private void backgroundWorkerCallTracker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                SalesForce sf = new SalesForce();
                RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\EZC");
                string department = "";
                if (rk.GetValue("SFD") != null)
                {
                    Global.Department = department = Crypto.Decrypt(rk.GetValue("SFD").ToString(), true);
                }
                else
                {
                    EZDebug.SendError("Department not set", "Call Tracking");
                    MessageBox.Show("Call Tracker will not be enabled until you set your current Deparment in the Sales Force Settings Menu" + Environment.NewLine + "Once you have set you options, please close and reopen EZC", "Call Tracker Disabled", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    backgroundWorkerCallTracker.Dispose();
                }
                if (sf.login(Global.sfUsername, Global.sfPassword, Global.sfToken))
                {
                    for (; ;)
                    {
                        Global.TicketHolder = sf.sfQ(department);
                        if (Global.TicketHolder != null)
                        {
                            if (!this.InvokeRequired)
                                return;
                                this.Invoke((Delegate)new MethodInvoker(CallTracking));
                        }

                        int timeout = 0;
                        while (true)
                        {
                            timeout = (60 - DateTime.Now.Second) * 1000 - DateTime.Now.Millisecond;
                            Thread.Sleep(timeout);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("login failed");
                }
            }
            catch (Exception ex)
            {
                EZDebug.SendError(ex.Message, "TicketTracker");
                backgroundWorkerCallTracker.RunWorkerAsync();
            }
        }

 

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Global.VPNType == "Cisco")
            {
                VPNConnect.DCisco();
            }
            else if (Global.VPNType == "Sonicwall")
            {
                VPNConnect.DSonicwall();
            }
            else
            {
                new SalesForce().logout();
                Environment.Exit(1);
            }
        }

 

 

I'm trying to bulk upsert some data, here is the structure

 

Account *parent*
Provider__c "child of Account*

Practice__c *child of Provider__c*

I always have the account id.

 

I need to add a new provider and its practices so I have something as follows.

 

Provider__c prov = new Provider__c;
Practice__c prac = new Practice__c;

prov.Account_Name__c = accountID;
prov.Name= "value";
...etc

prac.Provider__c = prov.ID
...etc

upsert(prov)
upsert(prac)

 
As you can see prov.ID is going to be empty so it flags an error trying to do the upsert.
How to I correctly link these items and upsert them?

Thanks