• hlotte
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Hi,

 

I'm trying to do a AJAX call with this class:

global class NetsizeTest { WebService static String Test(/*String contactId*/) { return 'Test'; } }

 

 and this APEX page :

<apex:page standardController="SMS__c" extensions="NetsizeClass">
<apex:sectionHeader title="New SMS" subtitle=""/>
<apex:includeScript value="/soap/ajax/16.0/connection.js"/>
<apex:includeScript value="/soap/ajax/16.0/apex.js"/>
<script>
function getMobileNumber(input)
{
sforce.debug.trace = true;
var c_id = document.all[input.id + '_lkid'].value;
try
{
var mobilePhone = sforce.apex.execute('NetsizeTest','Test',{/*contactId:c_id*/});
alert (mobilePhone);
} catch(e)
{
alert(e.faultCode?e.faultCode:e.message?e.message:e)
}

}
</script>

<apex:form >
<apex:pageBlock title="SMS information">
<TABLE>
<TR>
<TD><B>Contact</B></TD>
<TD><apex:inputField id="smsContact" value="{!sms.Contact__c}" onselect="javascript:getMobileNumber(this)"/></TD>
</TR>
<TR>
<TD><B>Mobile phone</B></TD>
<TD><apex:inputField id="smsMobilePhone" value="{!sms.MobilePhone__c}"/></TD>
</TR>
</TABLE>
<br/>
<apex:message for="smsContact" styleClass="" /> <p />
</apex:pageBlock>

</apex:form>
</apex:page>

 but when I do the call (without the try/catch in JS), I receive a Javascript error

Message: Exception thrown and not caught
Line: 1019
Char: 13
Code: 0
URI: https://c.cs2.visual.force.com/soap/ajax/16.0/connection.js

 

When I catch the error, I get this exception:

{faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', }

 

I get the same error with or without the parameters ContactId.

 

I get this information too, from the AJAX call debug

Request: server- /services/Soap/package/NetsizeTest

<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="http://soap.sforce.com/schemas/package/NetsizeTest"/><se:Body><Test xmlns="http://soap.sforce.com/schemas/package/NetsizeTest"/></se:Body></se:Envelope>

 

Response : status - 500

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="http://soap.sforce.com/schemas/package/NetsizeTest"><soapenv:Body><soapenv:Fault><faultcode>sf:INVALID_SESSION_ID</faultcode><faultstring>INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>

 

 

I checked the session settings : timout is 4h, 'Lock sessions to the IP ...' is unchecked.

 

I don't see any mentions to a session in the doc or examples I found

Am I missing something ?

 

Thanks in advance for your help

Hervé

 

 

  • August 17, 2009
  • Like
  • 0

Hi,

 

I'm totally newbie on Sales force, and I'm trying something that should be easy.

From a Case, I want to manage a new type of object, named SMS

I created the object and now I want to customize the page, with APEX

 

So, I created a class

 

global class NetsizeClass { private SMS__c currentSms; public SMS__c getSms() { return currentSms; } public NetsizeClass(ApexPages.StandardController controller) { if (currentSms == null) currentSms = new SMS__c(); string sms_id = System.currentPageReference().getParameters().get('id'); if (sms_id == null || sms_id == '') { // New SMS currentSms.message__c = 'New SMS '; } else currentSms= [select message__c, status__c, case__c, contact__c from SMS__c where id = :sms_id]; } public void SendSMS() { if (currentSms.id == null || currentSms.id == '')
// New SMS
else
// Existing SMS

upsert currentSms;
... } }

 

and a Page, that overload the 'New' button in my SMS object

 

<apex:page standardController="SMS__c" extensions="NetsizeClass"> <apex:sectionHeader title="New SMS" subtitle=""/> <apex:form> <apex:pageBlock title="SMS information"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Send SMS" action="{!SendSMS}"/> </apex:pageBlockButtons> <TABLE> <TR> <TD><B>Message</B></TD> <TD><apex:inputField value="{!sms.Message__c}" id="smsMsg"/></TD> </TR> <TR> <TD><B>Contact</B></TD> <TD><apex:inputField value="{!sms.Contact__c}" id="smsContact"/></TD> </TR> <TR> <TD><B>Case</B></TD> <TD><apex:inputField value="{!sms.Case__c}" id="smsCase"/></TD> </TR> <TR> <TD><B>Case 2</B></TD> <TD><apex:inputField value="{!SMS__c.Case__c}" id="smsCase2"/></TD> </TR> </TABLE> <br/> </apex:pageBlock> </apex:form> </apex:page>

 

It works fine, when I am on a Case, I see the button 'New SMS' (I customized the layout), that open my custom APEX page.

But I just don't know how to retreive the parent Case information (I'm using the 2 fields Case for my tests):

- the field smsCase is empty, and it's normal as it is linked to {!sms.Case__c} and sms is created in the constructor. But I read in some forums that it's the only way to retreive later the updated values (I want to customize the Edit and View page)

- the field smsCase2 is filled with the id of my Case, but I don't know how to retreive this data from my page.

 

I also would like to retreive automatically the contact linked in the parent Case, to link it to the SMS. But I think it should be easy to do when I'll have the ID of my Case.

 

I'm sure that I'm missing something but I searched in so much forums that I'm starting to mix-up everything.

Any help will be welcome :)

 

Thanks

Hervé

 

 

  • August 11, 2009
  • Like
  • 0

Hi,

 

I'm trying to do a AJAX call with this class:

global class NetsizeTest { WebService static String Test(/*String contactId*/) { return 'Test'; } }

 

 and this APEX page :

<apex:page standardController="SMS__c" extensions="NetsizeClass">
<apex:sectionHeader title="New SMS" subtitle=""/>
<apex:includeScript value="/soap/ajax/16.0/connection.js"/>
<apex:includeScript value="/soap/ajax/16.0/apex.js"/>
<script>
function getMobileNumber(input)
{
sforce.debug.trace = true;
var c_id = document.all[input.id + '_lkid'].value;
try
{
var mobilePhone = sforce.apex.execute('NetsizeTest','Test',{/*contactId:c_id*/});
alert (mobilePhone);
} catch(e)
{
alert(e.faultCode?e.faultCode:e.message?e.message:e)
}

}
</script>

<apex:form >
<apex:pageBlock title="SMS information">
<TABLE>
<TR>
<TD><B>Contact</B></TD>
<TD><apex:inputField id="smsContact" value="{!sms.Contact__c}" onselect="javascript:getMobileNumber(this)"/></TD>
</TR>
<TR>
<TD><B>Mobile phone</B></TD>
<TD><apex:inputField id="smsMobilePhone" value="{!sms.MobilePhone__c}"/></TD>
</TR>
</TABLE>
<br/>
<apex:message for="smsContact" styleClass="" /> <p />
</apex:pageBlock>

</apex:form>
</apex:page>

 but when I do the call (without the try/catch in JS), I receive a Javascript error

Message: Exception thrown and not caught
Line: 1019
Char: 13
Code: 0
URI: https://c.cs2.visual.force.com/soap/ajax/16.0/connection.js

 

When I catch the error, I get this exception:

{faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', }

 

I get the same error with or without the parameters ContactId.

 

I get this information too, from the AJAX call debug

Request: server- /services/Soap/package/NetsizeTest

<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="http://soap.sforce.com/schemas/package/NetsizeTest"/><se:Body><Test xmlns="http://soap.sforce.com/schemas/package/NetsizeTest"/></se:Body></se:Envelope>

 

Response : status - 500

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="http://soap.sforce.com/schemas/package/NetsizeTest"><soapenv:Body><soapenv:Fault><faultcode>sf:INVALID_SESSION_ID</faultcode><faultstring>INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>

 

 

I checked the session settings : timout is 4h, 'Lock sessions to the IP ...' is unchecked.

 

I don't see any mentions to a session in the doc or examples I found

Am I missing something ?

 

Thanks in advance for your help

Hervé

 

 

  • August 17, 2009
  • Like
  • 0

Hi,

 

I'm totally newbie on Sales force, and I'm trying something that should be easy.

From a Case, I want to manage a new type of object, named SMS

I created the object and now I want to customize the page, with APEX

 

So, I created a class

 

global class NetsizeClass { private SMS__c currentSms; public SMS__c getSms() { return currentSms; } public NetsizeClass(ApexPages.StandardController controller) { if (currentSms == null) currentSms = new SMS__c(); string sms_id = System.currentPageReference().getParameters().get('id'); if (sms_id == null || sms_id == '') { // New SMS currentSms.message__c = 'New SMS '; } else currentSms= [select message__c, status__c, case__c, contact__c from SMS__c where id = :sms_id]; } public void SendSMS() { if (currentSms.id == null || currentSms.id == '')
// New SMS
else
// Existing SMS

upsert currentSms;
... } }

 

and a Page, that overload the 'New' button in my SMS object

 

<apex:page standardController="SMS__c" extensions="NetsizeClass"> <apex:sectionHeader title="New SMS" subtitle=""/> <apex:form> <apex:pageBlock title="SMS information"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Send SMS" action="{!SendSMS}"/> </apex:pageBlockButtons> <TABLE> <TR> <TD><B>Message</B></TD> <TD><apex:inputField value="{!sms.Message__c}" id="smsMsg"/></TD> </TR> <TR> <TD><B>Contact</B></TD> <TD><apex:inputField value="{!sms.Contact__c}" id="smsContact"/></TD> </TR> <TR> <TD><B>Case</B></TD> <TD><apex:inputField value="{!sms.Case__c}" id="smsCase"/></TD> </TR> <TR> <TD><B>Case 2</B></TD> <TD><apex:inputField value="{!SMS__c.Case__c}" id="smsCase2"/></TD> </TR> </TABLE> <br/> </apex:pageBlock> </apex:form> </apex:page>

 

It works fine, when I am on a Case, I see the button 'New SMS' (I customized the layout), that open my custom APEX page.

But I just don't know how to retreive the parent Case information (I'm using the 2 fields Case for my tests):

- the field smsCase is empty, and it's normal as it is linked to {!sms.Case__c} and sms is created in the constructor. But I read in some forums that it's the only way to retreive later the updated values (I want to customize the Edit and View page)

- the field smsCase2 is filled with the id of my Case, but I don't know how to retreive this data from my page.

 

I also would like to retreive automatically the contact linked in the parent Case, to link it to the SMS. But I think it should be easy to do when I'll have the ID of my Case.

 

I'm sure that I'm missing something but I searched in so much forums that I'm starting to mix-up everything.

Any help will be welcome :)

 

Thanks

Hervé

 

 

  • August 11, 2009
  • Like
  • 0