• NewToSF
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
Hi,
 
 How do I convert datetime to ticks in apex?
 
Thanks.
Hi,
 
 I have a custom field number and I want to assign string variable to it. Giving me
"Illegal assignment from String to Double " error.
Are there any conversion functions provided in Apex?
 
Thanks.


Message Edited by NewToSF on 05-06-2008 08:46 AM
Hi,
 
  I am getting XML string from websrvice call. I want to parse that and update the custom object. I don't know how to parse the string like below.
 
<outloop status='success'><innerloop><value id='1242'></value></innerloop><error></error></outloop>
 
Pls. help.
 
Thanks,
 
Hi,
 
  I have a custom object Custom__c which has custom field Test__c. I have a custom button which calls(onclick javascript) a .net webservice returning some value that I want to update the Test__c with.
 
 Custom__c.Test__c = value didn't work. It says Custom__c is not defined.
 
I think I need to create a current instance of Custom__C class. But I don't have id for it. Can I create it on Name(field)? and how?
 
How should I go for it?
 
Thanks.


Message Edited by NewToSF on 04-15-2008 02:39 PM
Hi,
 
Here is my code. I have Custom__c object which has Admin person lookup to contacts. I need to find out the details of that contact. So I tried to use this query.
 
var c = sforce.connection.query("SELECT ID, Name  from Contact WHERE Contact.Id = '{!Custom__c.Primary_ContactId__c}'");
didn't return any records.
 
 So I tried this to check if Id's are same -
 
 var c = sforce.connection.query("SELECT ID, Name from Contact WHERE Contact.Name = '{!Custom__c.Primary_Contact__c}'");
var records = c.getArray("records");
alert(records[0].Id);
alert('{!Custom__c.Primary_ContactId__c}');

first alert i m getting is  - 0033000000ob70wAAB
and second - 0033000000ob75A
 
Why am I getting different ID's for same contact?
 
So what should I do to get the detail about Contacts from my custom object?
 
Thanks

Hi,
 
Here is my code. I have Custom__c object which has Admin person lookup to contacts. I need to find out the details of that contact. So I tried to use this query.
 
var c = sforce.connection.query("SELECT ID, Name  from Contact WHERE Contact.Id = '{!Custom__c.Primary_ContactId__c}'");
didn't return any records.
 
 So I tried this to check if Id's are same -
 
 var c = sforce.connection.query("SELECT ID, Name from Contact WHERE Contact.Name = '{!Custom__c.Primary_Contact__c}'");
var records = c.getArray("records");
alert(records[0].Id);
alert('{!Custom__c.Primary_ContactId__c}');

first alert i m getting is  - 0033000000ob70wAAB
and second - 0033000000ob75A
 
Why am I getting different ID's for same contact?
 
So what should I do to get the detail about Contacts from my custom object?
 
Thanks


Message Edited by NewToSF on 04-09-2008 02:05 PM
Hi,
 
  I have webservice written in .net located on my machine (I could see the web page located in same directory from URL type s-control in salesforce. so that means salesforce can access the files from that directory.)  I generated APex class from the WSDL(had to remove soap12 bindings).
 
//Generated by wsdl2apex
public class tempuriOrg {
    public class HelloWorld_element {
        public String arg;
        private String[] arg_type_info = new String[]{'arg','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'arg'};
    }
    public class testSalesForceSoap {
        public String endpoint_x = 'http://machineName/virtualdirectoryname/testSalesForce.asmx';
        private String[] ns_map_type_info = new String[]{'http://tempuri.org/', 'tempuriOrg'};
        public String HelloWorld(String arg) {
            tempuriOrg.HelloWorld_element request_x = new tempuriOrg.HelloWorld_element();
            tempuriOrg.HelloWorldResponse_element response_x;
            request_x.arg = arg;
            Map<String, tempuriOrg.HelloWorldResponse_element> response_map_x = new Map<String, tempuriOrg.HelloWorldResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/HelloWorld',
              'http://tempuri.org/',
              'HelloWorld',
              'http://tempuri.org/',
              'HelloWorldResponse',
              'tempuriOrg.HelloWorldResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.HelloWorldResult;
        }
    }
    public class HelloWorldResponse_element {
        public String HelloWorldResult;
        private String[] HelloWorldResult_type_info = new String[]{'HelloWorldResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'HelloWorldResult'};
    }
}
 
 
then I wrote wrapper apex class to call the apex code generated.
 
global class testSalesforce{
WebService static string test1(string name) {
tempuriOrg.testSalesForceSoap soap = new tempuriOrg.testSalesForceSoap();
return soap.HelloWorld('hello world !!! ' + name);}}
 
Then I created s-control to call this new webservice.
 
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/soap/ajax/10.0/apex.js"></script>
<script>
function X() {
try{
var result = sforce.apex.execute("testSalesforce" ,"test1", {arg:" hello"});
}
 catch (ex)
      {
       alert ("Failed : " + ex);
      }
}
</script>
</head>
<body onload=X()>
 <div id=userNameArea></div>
</body>
</html>
 
In security controls/remote site settings I have http://machinename url provided.
 
I am invoking the s-control on custom button click. when I give machinename in endpoint_x, I am getting:
System.CalloutException: Web service
    callout failed: Unexpected element. Parser was expecting element
    'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
 
and when I give ip address in endpoint_x and remote site settings I am getting :
IO Exception: Read Timed out
 
What do I need to do to get it working?
 
Thanks,


Message Edited by NewToSF on 04-01-2008 11:52 AM

Hi,

I have custom object X which has many custom members including Account(datatype is Lookup(Account)) which is related to Account object. When I create instance of getXInfoService in .net code after consuming webservice, I see x.Account__c and x.Account__r. Account__c is string and Account__r is null. How can I get Account object thru apex webservice?

global class getXInfo {

WebService static X__c getX(string xName) {

   X__c  z= [SELECT Account__c, API_Access__c from X__c WHERE X__c.Name =: xName];

    X__c n_z= new X__c(Account__c = z.Account__c, API_Access__c=z.API_Access__c);

   return n_z;

}

Hi there,

I need to update a checkbox on Object A , based off its related list which is Object B and also which is of LOANER record type.
Object A = CDM RMA (custom object)
Object B = RMA Add ON
Field to be updated = Loaner_Issued.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script language="JavaScript">

// Global Values

var isChanged = false; // set to true if the checkbox is placed on Loan Issued checkbox

// List checkbox fields here to compare the final values with
// CDM RMA is the object name and the Loaner_Issued is the customer checkbox.

var loanerIssued = {! CDM_RMA__c.Loaner_Issued__c};

// Function created to updated the checkbox.

function RmaAddon()
{

// Create temp account for updating

var updateCDM_RMA__c = new sforce.SObject("CDM_RMA__c");

// Update each CDM RMA record based on the ID.
  updateCDM_RMA__c.ID = '{!CDM_RMA__c.Id}';

// Get the RMA Add on lists attached to the CDM RMA object.
// Tried this too.(" SELECT Id, (SELECT Id, FROM R00N30000001Xi2lEAC WHERE RecordType.Name = 'Loaner') FROM CDM_RMA__c ");

var getprods = sforce.connection.query("SELECT r.Id, r.Name, CDM_RMA__r.Name FROM RMA_Add_On__c r WHERE CDM_RMA__r.Name = '{!CDM_RMA__c.Name}'");

var records = getprods.getArray ("records");

// Here I am checking that the RMA Add-On Type is Loaner based record type and if yes then place
// checkmark on the Loan Issued checkbox.
 
for(var i=0;i<records.length;i++){
dynaBean = records[i];

if(dynaBean.$Recordtype.Name == 'Loaner'){ // Record Type
updateCDM_RMA__c.Loaner_Issued__c = 1;                  // Checkbox is the checked.
if(loanerIssued == 0) isChanged = true;                  // variable name is TRUE becuase the checkbox value is changed from False to True
}
}

// If the CDM RMA record has been changed then save the new RMA Add on type for LOANER RecordType and save the record.


if(isChanged){
var saveResult = sforce.connection.update([updateCDM_RMA__c]);
if(saveResult[0].success){
window.parent.parent.location.href = '/{! CDM_RMA__c.Name }';
} else {
alert('There was an error when saving CDM RMA Record.');
}
}
}
</script>
</head>
<body>
<script>RmaAddon();</script>
</body>
</html>
////////////////////////////////////////////////////////////////////////

Here is the problem:-

1.> Either the SOQL is not correct
2.> I am unable to tell how to update a field based off Record Type
3.> Error =
dynaBean.$Recordtype has no properties
if(dynaBean.Recordtype.Name == 'Loaner'){ // Record Type

Thanks.

Hi,
 
Here is my code. I have Custom__c object which has Admin person lookup to contacts. I need to find out the details of that contact. So I tried to use this query.
 
var c = sforce.connection.query("SELECT ID, Name  from Contact WHERE Contact.Id = '{!Custom__c.Primary_ContactId__c}'");
didn't return any records.
 
 So I tried this to check if Id's are same -
 
 var c = sforce.connection.query("SELECT ID, Name from Contact WHERE Contact.Name = '{!Custom__c.Primary_Contact__c}'");
var records = c.getArray("records");
alert(records[0].Id);
alert('{!Custom__c.Primary_ContactId__c}');

first alert i m getting is  - 0033000000ob70wAAB
and second - 0033000000ob75A
 
Why am I getting different ID's for same contact?
 
So what should I do to get the detail about Contacts from my custom object?
 
Thanks

Hi,
 
Here is my code. I have Custom__c object which has Admin person lookup to contacts. I need to find out the details of that contact. So I tried to use this query.
 
var c = sforce.connection.query("SELECT ID, Name  from Contact WHERE Contact.Id = '{!Custom__c.Primary_ContactId__c}'");
didn't return any records.
 
 So I tried this to check if Id's are same -
 
 var c = sforce.connection.query("SELECT ID, Name from Contact WHERE Contact.Name = '{!Custom__c.Primary_Contact__c}'");
var records = c.getArray("records");
alert(records[0].Id);
alert('{!Custom__c.Primary_ContactId__c}');

first alert i m getting is  - 0033000000ob70wAAB
and second - 0033000000ob75A
 
Why am I getting different ID's for same contact?
 
So what should I do to get the detail about Contacts from my custom object?
 
Thanks


Message Edited by NewToSF on 04-09-2008 02:05 PM
Hi,
 
  I have webservice written in .net located on my machine (I could see the web page located in same directory from URL type s-control in salesforce. so that means salesforce can access the files from that directory.)  I generated APex class from the WSDL(had to remove soap12 bindings).
 
//Generated by wsdl2apex
public class tempuriOrg {
    public class HelloWorld_element {
        public String arg;
        private String[] arg_type_info = new String[]{'arg','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'arg'};
    }
    public class testSalesForceSoap {
        public String endpoint_x = 'http://machineName/virtualdirectoryname/testSalesForce.asmx';
        private String[] ns_map_type_info = new String[]{'http://tempuri.org/', 'tempuriOrg'};
        public String HelloWorld(String arg) {
            tempuriOrg.HelloWorld_element request_x = new tempuriOrg.HelloWorld_element();
            tempuriOrg.HelloWorldResponse_element response_x;
            request_x.arg = arg;
            Map<String, tempuriOrg.HelloWorldResponse_element> response_map_x = new Map<String, tempuriOrg.HelloWorldResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/HelloWorld',
              'http://tempuri.org/',
              'HelloWorld',
              'http://tempuri.org/',
              'HelloWorldResponse',
              'tempuriOrg.HelloWorldResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.HelloWorldResult;
        }
    }
    public class HelloWorldResponse_element {
        public String HelloWorldResult;
        private String[] HelloWorldResult_type_info = new String[]{'HelloWorldResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
        private String[] field_order_type_info = new String[]{'HelloWorldResult'};
    }
}
 
 
then I wrote wrapper apex class to call the apex code generated.
 
global class testSalesforce{
WebService static string test1(string name) {
tempuriOrg.testSalesForceSoap soap = new tempuriOrg.testSalesForceSoap();
return soap.HelloWorld('hello world !!! ' + name);}}
 
Then I created s-control to call this new webservice.
 
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/soap/ajax/10.0/apex.js"></script>
<script>
function X() {
try{
var result = sforce.apex.execute("testSalesforce" ,"test1", {arg:" hello"});
}
 catch (ex)
      {
       alert ("Failed : " + ex);
      }
}
</script>
</head>
<body onload=X()>
 <div id=userNameArea></div>
</body>
</html>
 
In security controls/remote site settings I have http://machinename url provided.
 
I am invoking the s-control on custom button click. when I give machinename in endpoint_x, I am getting:
System.CalloutException: Web service
    callout failed: Unexpected element. Parser was expecting element
    'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
 
and when I give ip address in endpoint_x and remote site settings I am getting :
IO Exception: Read Timed out
 
What do I need to do to get it working?
 
Thanks,


Message Edited by NewToSF on 04-01-2008 11:52 AM