• Logmi
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 9
    Replies
Hi!
 
Does anyone know why this line works in development mode only? 
 
After the user clicks save:
In development mode, the next page is lmi2.  Which is what I want.
In non-development mode, the it returns to standard edit page for the custom object. 
 
Thanks.
 
Code:
<apex:commandButton action="{!save}" value="Save" onclick="window.parent.location.href='/apex/lmi2'"/>

 

  • December 11, 2008
  • Like
  • 0
Hi,
I have created a new vf page (inexperienced and lost) that calls out to an external web services and displays information.  The data received is inserted into two custom tables.  Everything works fine except I cannot create a package because I only have 18% Test Coverage.  I noticed in my "Apex Test Result" a message in the Debug Log that says "Testmethods do not support webservice callouts".  Is that why I'm not getting 100%.  Is there anything I can do to get up to 75% so I can create a package?  Thanks!
Code:
public class LMIController {
  double output;

  public LogMeIn_Computers__c[] getComputers() 
  {
    String groupname = System.currentPageReference().getParameters().get('groupname');
    if(groupname==''){
      return [select Name, rescue__Offline_Since__c, rescue__hostid__c, 
          rescue__group__c,rescue__status__c,
          CreatedDate, CreatedBy.Name, 
          rescue__Remote__c from LogMeIn_Computers__c order by name];
    }
    else{ 
      return [select Name, rescue__Offline_Since__c, rescue__hostid__c, 
          rescue__group__c,rescue__status__c,
          CreatedDate, CreatedBy.Name, 
          rescue__Remote__c from LogMeIn_Computers__c where rescue__groupid__c =:groupname order by name];
    }
  }

  public ITRGroups__c[] getGroups() 
  {
    return [select Name, rescue__Id__c from ITRGroups__c order by name];
  }

  public PageReference newComputer() {
    PageReference pr = Page.lmi_itreach;
    pr.setredirect(true);
    return pr;
  }

  public void refreshComputers() 
  {
    String cred = getCred();
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://secure.logmein.com/ws/hostGetList.asp'+cred); 
    req.setMethod('GET');
    HttpResponse res = h.send(req);

    List<String> rows = new String[1000];
    List<String> afs = new String[1000];
    List<String> urls = new String[1000];
    LogMeIn_Computers__c newHost = new LogMeIn_Computers__c();

    rows = res.getBody().split('\n');

    if(rows[0]=='ERROR:4') {
      return;}

    Integer i = 0;
    
    List<rescue__LogMeIn_Computers__c> allRec = new List<rescue__LogMeIn_Computers__c>();

    for (String tempString : rows) {
      i = i + 1;
      if(i>2){
        afs = tempString.split('\t');
        urls[i] = rGetURL(afs[0]);
      }
    }
    
    i = 0;
    for (String tempString : rows) {
      i = i + 1;
      if(i>2){
        afs = tempString.split('\t');
        if(afs[0]<>''){
          rescue__LogMeIn_Computers__c singleRec = new rescue__LogMeIn_Computers__c();
          if(afs[2]=='0'){
            singleRec.rescue__status__c = 'Offline';}
          else {
            singleRec.rescue__status__c = 'Online';}
          singleRec.name = afs[1];
          singleRec.rescue__hostid__c=afs[0];
          singleRec.rescue__Offline_Since__c=afs[3];
          if(afs[3]==''){
            singleRec.rescue__Offline_Since__c = 'n/a';}
          singleRec.rescue__group__c=findGroup(afs[4]);
          singleRec.rescue__groupid__c=afs[4];
          singleRec.rescue__remote__c=urls[i];
          allRec.add(singleRec);
    upsert allRec rescue__hostid__c;
        }
      }
    }

  }
   
  public string findGroup(String grpId){
    rescue__ITRGroups__c[] ITRGroup = [select name from rescue__ITRGroups__c where rescue__Id__c = :grpId LIMIT 1];
    if(ITRGroup.size()==0){
      List<rescue__ITRGroups__c> groupToCreate = new List<rescue__ITRGroups__c>();
      rescue__ITRGroups__c newgrp = new rescue__ITRGroups__c(name='Group ('+grpId+')', rescue__Id__c = grpId);
      groupToCreate.add(newgrp);
      upsert groupToCreate;
      return 'Group ('+grpId+')';
      }
    return ITRGroup[0].name;
  }

  public string rGetURL(String hostId)
  {
    String cred = getCred();
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://secure.logmein.com/ws/hostConnect.asp'+cred+'&hostid='+hostId); 
    req.setMethod('GET');
    HttpResponse res = h.send(req);
    
    List<String> rows = new String[1000];
    List<String> afs = new String[1000];

    rows = res.getBody().split('\n');
    
    if(rows[0]=='OK'){
      return rows[1].substring(4);}
    else{
      return rows[0];}

  }
    
  public String getCred() 
  {
    rescue__Globals__c r = new rescue__Globals__c();
    r = [select rescue__value__c from rescue__Globals__c where name='psk'];
    String psk = r.rescue__value__c;
    r = [select rescue__value__c from rescue__Globals__c where name='companyid'];
    String companyid= r.rescue__value__c;
    return '—companyid='+companyid+'&psk='+psk;
  }   
}

 
Code:
public class LMIControllerTests {
public static testMethod void testMyController() {

LMIController controller = new LMIController();

controller = new LMIController();
controller.refreshComputers();
}}

 

  • December 09, 2008
  • Like
  • 0

Hi,

Thank you for any help.  I have the S-control below.  I added a custom button to a new tab I created.  If I select the "Content Source" as "Custom S-Control"  it works fine.  However is I select "OnClick JavaSript" instead, I get an message

"A problem with the OnClick JavaScript for this button or link was encountered.  missing = in XML attribute".

Do you know what I'm missing? 

Code:
<script src="/soap/ajax/14.0/connection.js"
type="text/javascript"></script>
<script>
var psk = "x";
var companyid= "1"; 
gethostlist();
function gethostlist() {


var envelope ='<—xml version="1.0" encoding="utf-8"–>'+
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'+
'<soap12:Body>'+
'<gethostslist xmlns="https://secure.site.com/ws/hostGetList.asp˜companyid='+companyid+'&psk'+psk+'">'+
'</gethostslist>'+
'</soap12:Body>'+
'</soap12:Envelope>';


sforce.connection.remoteFunction({
url : "https://secure.site.com/ws/hostGetList.asp™companyid="+companyid+"&psk="+psk,
requestHeaders: {
"Content-Type": "xml",
"SOAPAction": "https://secure.site.com/ws/hostGetList.asp?companyid="+companyid+"&psk="+psk
},

requestData: envelope,
method: "POST",
onSuccess : function(response) {
if(response.substr(0,2)=="OK")
{
alert("success")
convertThis(response);
}
else
{
alert("fail")
}
},
onFailure : function(response) {
}
}); 
return;
}


 

  • November 24, 2008
  • Like
  • 1
Hi.  I'm having some trouble understanding GMT UTC and local time.  I am creating a task object with a datetime fields.  Here is the code I'm using.
 

DateTime tempTime;

tempTime = new DateTime();

if (PickupTime.Length > 0)

{

tempTime = DateTime.ParseExact(PickupTime, "yyyy-MM-dd HH:mm:ss", null);

tk[10] = doc.CreateElement("Local_Pickup_Time__c");

tk[10].InnerText = (tempTime.ToUniversalTime()).ToString("s");

}

If I have a value PickupTime = "2008-11-03 19:18:53", which is 2:18pm EST, the value I end up with in my Local_Pickup_Time_cc is 11/3/2008 1:18 PM.  Which is one hour earlier.  Does anyone know why?

  • November 03, 2008
  • Like
  • 0


Message Edited by Logmi on 11-03-2008 11:34 AM

Message Edited by Logmi on 11-03-2008 11:34 AM
  • October 07, 2008
  • Like
  • 0
Can anybody please tell me what I'm doing wrong?  I'm using this sql in a query.  It returns zero records, but I know there is a Case with CaseNumber equal to 00001031.
 
"SELECT Id, CaseNumber, Account.Id, Account.Name,Owner.FirstName, Owner.LastName, Account.Phone FROM Case WHERE CaseNumber = '00001031' ORDER BY Account.Name"
  • August 12, 2008
  • Like
  • 0
Hi - I was using the code below to create new Task records using the enterprise wsdl.  Once my code was certified, I tried to incorporate the Client ID but was told it can only be used with the partner wsdl.  I'm having problems getting my code to work with the partner wsdl with an error of "INVALID_TYPE".  Can you see what I'm doing wrong?
 
Old code using Enterprise wsdl:
Code:
            SforceService sfdc = new SforceService();
            sfdc.Url = tracking[0];
            sfdc.SessionHeaderValue = new SessionHeader();
            sfdc.SessionHeaderValue.sessionId = tracking[2];
            Integration.sforce.Task[] task = new Task[1];
            task[0] = new Integration.sforce.Task();
            task[0].WhatId = tracking[1];
            task[0].IsClosed = true;
            task[0].Subject = "Rescue Session " + SessionID;
            task[0].Description = ChatLog + "  Session Notes: " + Note;
            task[0].LastModifiedDate = DateTime.Now;
            task[0].rescue__TechID__c = TechID;
            task[0].rescue__TechName__c = TechName;
            task[0].rescue__WaitingTime__c = WaitingTime;
            task[0].rescue__PickupTime__c = PickupTime;
            task[0].rescue__ClosingTime__c = ClosingTime;
            task[0].rescue__TechDescr__c = TechDescr;
            task[0].IsClosed = true;
            task[0].Status = "Completed";
            Integration.sforce.UpsertResult ur = sfdc.upsert("Id", task)[0];


New Code that doesn't work using Partner wsdl:

Code:
            SforceService sfdc = new SforceService();
            sfdc.Url = tracking[0];
            sfdc.SessionHeaderValue = new SessionHeader();
            String clientID = "xxxxxxxxxxx";
            CallOptions co = new CallOptions();
            co.client = clientID;
            sfdc.CallOptionsValue = co;
            sfdc.SessionHeaderValue.sessionId = tracking[2];
            Integration.sforce2.sObject tk;
            sObject[] tasks = new sObject[1];
            tk = new Integration.sforce2.sObject();
            System.Xml.XmlElement[] task = new System.Xml.XmlElement[12];
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            task[0] = doc.CreateElement("IsClosed"); task[0].InnerText = "true";
            task[1] = doc.CreateElement("Subject"); task[1].InnerText = "Rescue Session " + SessionID;
            task[2] = doc.CreateElement("Description"); task[2].InnerText = ChatLog + "  Session Notes: " + Note;
            task[3] = doc.CreateElement("LastModifiedDate"); task[3].InnerText = DateTime.Now.ToString("d");
            task[4] = doc.CreateElement("TechID__c"); task[4].InnerText = TechID;
            task[5] = doc.CreateElement("TechName__c"); task[5].InnerText = TechName;
            task[6] = doc.CreateElement("WaitingTime__c"); task[6].InnerText = WaitingTime;
            task[7] = doc.CreateElement("PickupTime__c"); task[7].InnerText = PickupTime;
            task[8] = doc.CreateElement("ClosingTime__c"); task[8].InnerText = ClosingTime;
            task[9] = doc.CreateElement("TechDescr__c"); task[9].InnerText = TechDescr;
            task[10] = doc.CreateElement("IsClosed"); task[10].InnerText = "true";
            task[11] = doc.CreateElement("Status"); task[11].InnerText = "Completed";
            tk.type = "Task";
            tk.Any = task;
            tasks[0] = tk;
            SaveResult[] sr = sfdc.create(tasks);


 
 

  • June 03, 2008
  • Like
  • 0
I have a question about the security settings in IE and FireFox.  I created the custom s-control below.  xmlhttp request works fine in IE if I enable "Access data sources across domains", but I doesn't work in Firefox.  I would prefer not touching any of the security settings in either browser to make this work.  Can anyone give me a suggestion?
 
CUSTOM S-CONTROL
<html>
<head>
<meta http-equiv=“refresh” content=“600″ />
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript">
var message;
var xmlhttp;
var pin;
if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
//  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") ;
}
try
{
if (xmlhttp)
{
// Get new PIN
xmlhttp.open('GET', 'https://secure.help.com/API/requestPINCode.aspx?lang=en&redir=0&NewWindow=0&cfield0={!Case.Account}&cfield1={!API.Session_ID}&cfield2={!Case.OwnerEmail}&cfield3={!Case.Id}&cfield4={!Case.AssetId}&cfield5={!API.Enterprise_Server_URL_100}tracking0={!Case.Id}', false);
xmlhttp.send();
if (xmlhttp.responseText.search("OK\n\n") == 0)
{
pin = xmlhttp.responseText.substring(12);
message = '<a href="mailto:{!Contact.Email}?subject=Direct Connect Links&body=Please click the link below to request a live support session%0A%0Ahttps://secure.help.com/R%3Fi=2%26Code='+pin+'%0A%0ABest Regards,%0ASupport Teams"><br>Send email</a>';
message = pin + message;
//myWindow=window.open('','','width=450,height=180,titlebar=no,menubar=no,resizable=no,titlebar=no,status=no')
document.write("<h4><p style='color:blue;'>PIN Code: " + message +"</p></h4>")
//myWindow.document.write(message) 
document.write("This PIN code will remain valid for the next 20 minutes.<br><br>")
document.write('<div align=right><INPUT type="button" value="Close" name="button1" onClick=self.close();return true"></div>')
}
else
{
document.write("You are not logged on. Please" + '\n' + "launch the application before requesting a PIN by clicking the" + '\n' + "'Launch' button.")
}
}
else
{
document.write("Rescue API: Unable to generate PIN code.")
}
}
catch (e) {
document.write("Your browser's security settings is preventing this application from calling a web service.  Please check your settings and try again -  " + e);
}
</script>
</head>
<body bgcolor="#EEEEEE">
<font size="2" face="Garamond">
<div id="div_tag"></div></font>
</body>
</html>
  • February 08, 2008
  • Like
  • 0
Hello,
I have created a custom button to display in new window where the content source is a custom s-control (HTML).  All works well but I would like to be able to control the properties of the window before it opens (size, scroolbars, statusbar, toolbar).  Where can I find those properties?
Thanks!!!
  • February 08, 2008
  • Like
  • 0
Hi - I've created a web service to upsert to the TASK table.  The upsert works and the item shows up in the Activity History.  Is it possible to remove the edit link for this item?  I don't want people to be able to change it.  There is also an EDIT button when they view the task detials that I would need to remove.  Also, can you tell me how to put a value into the field labelled NAME?  Data type is Lookup(Contact,Lead).
 
I've include the code just in case...
 
Thanks you!
 

        [WebMethod]

        public string APEXUPSERT(string SessionID,

               string TechID, string TechName, string SSOID, string TechDescr,

               string Status, string CField0, string CField1, string CField2,

               string CField3, string CField4, string CField5, string ChatLog,

               string WaitingTime, string PickupTime, string ClosingTime)

        {

            SforceService sfdc = new SforceService();

            sfdc.Url = CField5;

            sfdc.SessionHeaderValue = new SessionHeader();

            sfdc.SessionHeaderValue.sessionId = CField1;

            sforce.Task[] task = new Task[1];

            task[0] = new sforce.Task();

            task[0].WhatId = CField3;

            task[0].IsClosed = true;

            task[0].Subject = "Rescue Session";

            task[0].Description = ChatLog;

            task[0].LastModifiedDate = DateTime.Now;

            task[0].TechID__c = TechID;

            task[0].TechName__c = TechName;

            task[0].WaitingTime__c = WaitingTime;

            task[0].PickupTime__c = PickupTime;

            task[0].ClosingTime__c = ClosingTime;

            task[0].TechDescr__c = TechDescr;

            task[0].IsClosed = true;

            task[0].Status = "Completed";

            sforce.UpsertResult ur = sfdc.upsert("Id", task)[0];

 

                if (ur.success)

                {

                    return "OK";

                }

                else

                { 

                    return "ERROR";

                  

                }

        }   

  • February 07, 2008
  • Like
  • 0
Does anyone have any experience using the encrypted fields feature?  I have added an encrypted custom field to the USER object where I store a password.  I want to use this field in some javascript in a custom button.  Like this...
 
if (xmlhttp)
{xmlhttp.open('GET', 'https://somepage.com/api/login.aspx?email={!User.Remail__c}&pwd={!User.RPassword__c}', false);
xmlhttp.send();
I'm guessing it's still encrypted when it sends the request because it doesn't work.  Is this even possible?  I appreciate the help!!
  • January 23, 2008
  • Like
  • 0
Hi,
We are in the preliminary stages integrating SalesForce with our web application.  I need some data generated in our app to be saved to its related case in SalesForce. 
1. Is it possible to pass the Case ID and Session ID from SalesForce to our app (using our API through an S-Control)?  And in turn, our app call the the Apex API web service to insert/update the case in SalesForce.
2. Is a logon call required to log in to the login server and starts a client session or can we just use Session ID and do an upsert?
 
I'm sure I don't need the SF username and passord in our app to access the API, I just don't know how it's done.  know these are pretty general questions, but I would very much appreciate your input to get us on the right track.
Sero
 
  • December 10, 2007
  • Like
  • 0

Hi,

Thank you for any help.  I have the S-control below.  I added a custom button to a new tab I created.  If I select the "Content Source" as "Custom S-Control"  it works fine.  However is I select "OnClick JavaSript" instead, I get an message

"A problem with the OnClick JavaScript for this button or link was encountered.  missing = in XML attribute".

Do you know what I'm missing? 

Code:
<script src="/soap/ajax/14.0/connection.js"
type="text/javascript"></script>
<script>
var psk = "x";
var companyid= "1"; 
gethostlist();
function gethostlist() {


var envelope ='<—xml version="1.0" encoding="utf-8"–>'+
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'+
'<soap12:Body>'+
'<gethostslist xmlns="https://secure.site.com/ws/hostGetList.asp˜companyid='+companyid+'&psk'+psk+'">'+
'</gethostslist>'+
'</soap12:Body>'+
'</soap12:Envelope>';


sforce.connection.remoteFunction({
url : "https://secure.site.com/ws/hostGetList.asp™companyid="+companyid+"&psk="+psk,
requestHeaders: {
"Content-Type": "xml",
"SOAPAction": "https://secure.site.com/ws/hostGetList.asp?companyid="+companyid+"&psk="+psk
},

requestData: envelope,
method: "POST",
onSuccess : function(response) {
if(response.substr(0,2)=="OK")
{
alert("success")
convertThis(response);
}
else
{
alert("fail")
}
},
onFailure : function(response) {
}
}); 
return;
}


 

  • November 24, 2008
  • Like
  • 1
Hi,
I have created a new vf page (inexperienced and lost) that calls out to an external web services and displays information.  The data received is inserted into two custom tables.  Everything works fine except I cannot create a package because I only have 18% Test Coverage.  I noticed in my "Apex Test Result" a message in the Debug Log that says "Testmethods do not support webservice callouts".  Is that why I'm not getting 100%.  Is there anything I can do to get up to 75% so I can create a package?  Thanks!
Code:
public class LMIController {
  double output;

  public LogMeIn_Computers__c[] getComputers() 
  {
    String groupname = System.currentPageReference().getParameters().get('groupname');
    if(groupname==''){
      return [select Name, rescue__Offline_Since__c, rescue__hostid__c, 
          rescue__group__c,rescue__status__c,
          CreatedDate, CreatedBy.Name, 
          rescue__Remote__c from LogMeIn_Computers__c order by name];
    }
    else{ 
      return [select Name, rescue__Offline_Since__c, rescue__hostid__c, 
          rescue__group__c,rescue__status__c,
          CreatedDate, CreatedBy.Name, 
          rescue__Remote__c from LogMeIn_Computers__c where rescue__groupid__c =:groupname order by name];
    }
  }

  public ITRGroups__c[] getGroups() 
  {
    return [select Name, rescue__Id__c from ITRGroups__c order by name];
  }

  public PageReference newComputer() {
    PageReference pr = Page.lmi_itreach;
    pr.setredirect(true);
    return pr;
  }

  public void refreshComputers() 
  {
    String cred = getCred();
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://secure.logmein.com/ws/hostGetList.asp'+cred); 
    req.setMethod('GET');
    HttpResponse res = h.send(req);

    List<String> rows = new String[1000];
    List<String> afs = new String[1000];
    List<String> urls = new String[1000];
    LogMeIn_Computers__c newHost = new LogMeIn_Computers__c();

    rows = res.getBody().split('\n');

    if(rows[0]=='ERROR:4') {
      return;}

    Integer i = 0;
    
    List<rescue__LogMeIn_Computers__c> allRec = new List<rescue__LogMeIn_Computers__c>();

    for (String tempString : rows) {
      i = i + 1;
      if(i>2){
        afs = tempString.split('\t');
        urls[i] = rGetURL(afs[0]);
      }
    }
    
    i = 0;
    for (String tempString : rows) {
      i = i + 1;
      if(i>2){
        afs = tempString.split('\t');
        if(afs[0]<>''){
          rescue__LogMeIn_Computers__c singleRec = new rescue__LogMeIn_Computers__c();
          if(afs[2]=='0'){
            singleRec.rescue__status__c = 'Offline';}
          else {
            singleRec.rescue__status__c = 'Online';}
          singleRec.name = afs[1];
          singleRec.rescue__hostid__c=afs[0];
          singleRec.rescue__Offline_Since__c=afs[3];
          if(afs[3]==''){
            singleRec.rescue__Offline_Since__c = 'n/a';}
          singleRec.rescue__group__c=findGroup(afs[4]);
          singleRec.rescue__groupid__c=afs[4];
          singleRec.rescue__remote__c=urls[i];
          allRec.add(singleRec);
    upsert allRec rescue__hostid__c;
        }
      }
    }

  }
   
  public string findGroup(String grpId){
    rescue__ITRGroups__c[] ITRGroup = [select name from rescue__ITRGroups__c where rescue__Id__c = :grpId LIMIT 1];
    if(ITRGroup.size()==0){
      List<rescue__ITRGroups__c> groupToCreate = new List<rescue__ITRGroups__c>();
      rescue__ITRGroups__c newgrp = new rescue__ITRGroups__c(name='Group ('+grpId+')', rescue__Id__c = grpId);
      groupToCreate.add(newgrp);
      upsert groupToCreate;
      return 'Group ('+grpId+')';
      }
    return ITRGroup[0].name;
  }

  public string rGetURL(String hostId)
  {
    String cred = getCred();
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://secure.logmein.com/ws/hostConnect.asp'+cred+'&hostid='+hostId); 
    req.setMethod('GET');
    HttpResponse res = h.send(req);
    
    List<String> rows = new String[1000];
    List<String> afs = new String[1000];

    rows = res.getBody().split('\n');
    
    if(rows[0]=='OK'){
      return rows[1].substring(4);}
    else{
      return rows[0];}

  }
    
  public String getCred() 
  {
    rescue__Globals__c r = new rescue__Globals__c();
    r = [select rescue__value__c from rescue__Globals__c where name='psk'];
    String psk = r.rescue__value__c;
    r = [select rescue__value__c from rescue__Globals__c where name='companyid'];
    String companyid= r.rescue__value__c;
    return '—companyid='+companyid+'&psk='+psk;
  }   
}

 
Code:
public class LMIControllerTests {
public static testMethod void testMyController() {

LMIController controller = new LMIController();

controller = new LMIController();
controller.refreshComputers();
}}

 

  • December 09, 2008
  • Like
  • 0
Hi.  I'm having some trouble understanding GMT UTC and local time.  I am creating a task object with a datetime fields.  Here is the code I'm using.
 

DateTime tempTime;

tempTime = new DateTime();

if (PickupTime.Length > 0)

{

tempTime = DateTime.ParseExact(PickupTime, "yyyy-MM-dd HH:mm:ss", null);

tk[10] = doc.CreateElement("Local_Pickup_Time__c");

tk[10].InnerText = (tempTime.ToUniversalTime()).ToString("s");

}

If I have a value PickupTime = "2008-11-03 19:18:53", which is 2:18pm EST, the value I end up with in my Local_Pickup_Time_cc is 11/3/2008 1:18 PM.  Which is one hour earlier.  Does anyone know why?

  • November 03, 2008
  • Like
  • 0


Message Edited by Logmi on 11-03-2008 11:34 AM

Message Edited by Logmi on 11-03-2008 11:34 AM
  • October 07, 2008
  • Like
  • 0
Hi - I was using the code below to create new Task records using the enterprise wsdl.  Once my code was certified, I tried to incorporate the Client ID but was told it can only be used with the partner wsdl.  I'm having problems getting my code to work with the partner wsdl with an error of "INVALID_TYPE".  Can you see what I'm doing wrong?
 
Old code using Enterprise wsdl:
Code:
            SforceService sfdc = new SforceService();
            sfdc.Url = tracking[0];
            sfdc.SessionHeaderValue = new SessionHeader();
            sfdc.SessionHeaderValue.sessionId = tracking[2];
            Integration.sforce.Task[] task = new Task[1];
            task[0] = new Integration.sforce.Task();
            task[0].WhatId = tracking[1];
            task[0].IsClosed = true;
            task[0].Subject = "Rescue Session " + SessionID;
            task[0].Description = ChatLog + "  Session Notes: " + Note;
            task[0].LastModifiedDate = DateTime.Now;
            task[0].rescue__TechID__c = TechID;
            task[0].rescue__TechName__c = TechName;
            task[0].rescue__WaitingTime__c = WaitingTime;
            task[0].rescue__PickupTime__c = PickupTime;
            task[0].rescue__ClosingTime__c = ClosingTime;
            task[0].rescue__TechDescr__c = TechDescr;
            task[0].IsClosed = true;
            task[0].Status = "Completed";
            Integration.sforce.UpsertResult ur = sfdc.upsert("Id", task)[0];


New Code that doesn't work using Partner wsdl:

Code:
            SforceService sfdc = new SforceService();
            sfdc.Url = tracking[0];
            sfdc.SessionHeaderValue = new SessionHeader();
            String clientID = "xxxxxxxxxxx";
            CallOptions co = new CallOptions();
            co.client = clientID;
            sfdc.CallOptionsValue = co;
            sfdc.SessionHeaderValue.sessionId = tracking[2];
            Integration.sforce2.sObject tk;
            sObject[] tasks = new sObject[1];
            tk = new Integration.sforce2.sObject();
            System.Xml.XmlElement[] task = new System.Xml.XmlElement[12];
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            task[0] = doc.CreateElement("IsClosed"); task[0].InnerText = "true";
            task[1] = doc.CreateElement("Subject"); task[1].InnerText = "Rescue Session " + SessionID;
            task[2] = doc.CreateElement("Description"); task[2].InnerText = ChatLog + "  Session Notes: " + Note;
            task[3] = doc.CreateElement("LastModifiedDate"); task[3].InnerText = DateTime.Now.ToString("d");
            task[4] = doc.CreateElement("TechID__c"); task[4].InnerText = TechID;
            task[5] = doc.CreateElement("TechName__c"); task[5].InnerText = TechName;
            task[6] = doc.CreateElement("WaitingTime__c"); task[6].InnerText = WaitingTime;
            task[7] = doc.CreateElement("PickupTime__c"); task[7].InnerText = PickupTime;
            task[8] = doc.CreateElement("ClosingTime__c"); task[8].InnerText = ClosingTime;
            task[9] = doc.CreateElement("TechDescr__c"); task[9].InnerText = TechDescr;
            task[10] = doc.CreateElement("IsClosed"); task[10].InnerText = "true";
            task[11] = doc.CreateElement("Status"); task[11].InnerText = "Completed";
            tk.type = "Task";
            tk.Any = task;
            tasks[0] = tk;
            SaveResult[] sr = sfdc.create(tasks);


 
 

  • June 03, 2008
  • Like
  • 0
I have a question about the security settings in IE and FireFox.  I created the custom s-control below.  xmlhttp request works fine in IE if I enable "Access data sources across domains", but I doesn't work in Firefox.  I would prefer not touching any of the security settings in either browser to make this work.  Can anyone give me a suggestion?
 
CUSTOM S-CONTROL
<html>
<head>
<meta http-equiv=“refresh” content=“600″ />
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript">
var message;
var xmlhttp;
var pin;
if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
//  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") ;
}
try
{
if (xmlhttp)
{
// Get new PIN
xmlhttp.open('GET', 'https://secure.help.com/API/requestPINCode.aspx?lang=en&redir=0&NewWindow=0&cfield0={!Case.Account}&cfield1={!API.Session_ID}&cfield2={!Case.OwnerEmail}&cfield3={!Case.Id}&cfield4={!Case.AssetId}&cfield5={!API.Enterprise_Server_URL_100}tracking0={!Case.Id}', false);
xmlhttp.send();
if (xmlhttp.responseText.search("OK\n\n") == 0)
{
pin = xmlhttp.responseText.substring(12);
message = '<a href="mailto:{!Contact.Email}?subject=Direct Connect Links&body=Please click the link below to request a live support session%0A%0Ahttps://secure.help.com/R%3Fi=2%26Code='+pin+'%0A%0ABest Regards,%0ASupport Teams"><br>Send email</a>';
message = pin + message;
//myWindow=window.open('','','width=450,height=180,titlebar=no,menubar=no,resizable=no,titlebar=no,status=no')
document.write("<h4><p style='color:blue;'>PIN Code: " + message +"</p></h4>")
//myWindow.document.write(message) 
document.write("This PIN code will remain valid for the next 20 minutes.<br><br>")
document.write('<div align=right><INPUT type="button" value="Close" name="button1" onClick=self.close();return true"></div>')
}
else
{
document.write("You are not logged on. Please" + '\n' + "launch the application before requesting a PIN by clicking the" + '\n' + "'Launch' button.")
}
}
else
{
document.write("Rescue API: Unable to generate PIN code.")
}
}
catch (e) {
document.write("Your browser's security settings is preventing this application from calling a web service.  Please check your settings and try again -  " + e);
}
</script>
</head>
<body bgcolor="#EEEEEE">
<font size="2" face="Garamond">
<div id="div_tag"></div></font>
</body>
</html>
  • February 08, 2008
  • Like
  • 0
Hello,
I have created a custom button to display in new window where the content source is a custom s-control (HTML).  All works well but I would like to be able to control the properties of the window before it opens (size, scroolbars, statusbar, toolbar).  Where can I find those properties?
Thanks!!!
  • February 08, 2008
  • Like
  • 0
Hi - I've created a web service to upsert to the TASK table.  The upsert works and the item shows up in the Activity History.  Is it possible to remove the edit link for this item?  I don't want people to be able to change it.  There is also an EDIT button when they view the task detials that I would need to remove.  Also, can you tell me how to put a value into the field labelled NAME?  Data type is Lookup(Contact,Lead).
 
I've include the code just in case...
 
Thanks you!
 

        [WebMethod]

        public string APEXUPSERT(string SessionID,

               string TechID, string TechName, string SSOID, string TechDescr,

               string Status, string CField0, string CField1, string CField2,

               string CField3, string CField4, string CField5, string ChatLog,

               string WaitingTime, string PickupTime, string ClosingTime)

        {

            SforceService sfdc = new SforceService();

            sfdc.Url = CField5;

            sfdc.SessionHeaderValue = new SessionHeader();

            sfdc.SessionHeaderValue.sessionId = CField1;

            sforce.Task[] task = new Task[1];

            task[0] = new sforce.Task();

            task[0].WhatId = CField3;

            task[0].IsClosed = true;

            task[0].Subject = "Rescue Session";

            task[0].Description = ChatLog;

            task[0].LastModifiedDate = DateTime.Now;

            task[0].TechID__c = TechID;

            task[0].TechName__c = TechName;

            task[0].WaitingTime__c = WaitingTime;

            task[0].PickupTime__c = PickupTime;

            task[0].ClosingTime__c = ClosingTime;

            task[0].TechDescr__c = TechDescr;

            task[0].IsClosed = true;

            task[0].Status = "Completed";

            sforce.UpsertResult ur = sfdc.upsert("Id", task)[0];

 

                if (ur.success)

                {

                    return "OK";

                }

                else

                { 

                    return "ERROR";

                  

                }

        }   

  • February 07, 2008
  • Like
  • 0
Does anyone have any experience using the encrypted fields feature?  I have added an encrypted custom field to the USER object where I store a password.  I want to use this field in some javascript in a custom button.  Like this...
 
if (xmlhttp)
{xmlhttp.open('GET', 'https://somepage.com/api/login.aspx?email={!User.Remail__c}&pwd={!User.RPassword__c}', false);
xmlhttp.send();
I'm guessing it's still encrypted when it sends the request because it doesn't work.  Is this even possible?  I appreciate the help!!
  • January 23, 2008
  • Like
  • 0