• danwilkie
  • NEWBIE
  • 25 Points
  • Member since 2009

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

I am trying to do a callout that logon's to a webservice and then returns an xml file.  I am trying to set the response header's content-type to be application-xml, but only see a setHeader method on the HttpRequest object.  

 

I am having a problem setting the Content-Type header with the below code.  When I check the Content-Type of the HttpResponse object, the value isn't 'application/xml' as I expected. 

 

Is this the correct approach?

 

 

Http http = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setHeader('Content-Type', 'application/xml'); req.setEndpoint('https://something./rest/clientauth/authenticate?account=xxx&password=xxx&source=xxx'); try { //Execute web service call here HTTPResponse res = http.send(req); //Helpful debug messages System.debug(res.toString()); System.debug('STATUS:'+res.getStatus()); System.debug('STATUS_CODE:'+res.getStatusCode()); System.debug('Content-Type:'+ res.getHeader('Content-Type')); } catch (System.CalloutException e) { system.debug('SKM-CalloutException occurred'); }

 

 

 

 

Hi,

 

We are using Single-Sign on to allow customers to log into the customer portal without having to enter their login details. The problem is, if this single-sign on fails for whatever reason, the customer reaches a Customer Portal login page (login_portal.jsp), with the username already filled in, and asking for a password. This will be confusing for our customers if it happens, as theyhaven't knowingly entered a username or password (as their login is handled by the single sign on).

 

The question is, is it possible to designate a redirect page (or at least a message to be displayed) if the single sign on fails? I have seen that we can designate a page to arrive at for successful logins and logouts, but I haven't found a way of definining what happens if the login fails - we do not want this login page (login_portal.jsp) to be displayed.

 

Any ideas will be greatly appreciated

 

Thanks,

 

Dan

We have a set number of customer portal user licenses available, and we would like to take action when we reach this limit (or ideally when we get near this limit but have not yet reached it).

 

I think it is possible to find out the number of cp licenses currently in use (select users where the isActive=true and the profile is Customer Portal User), however we need to be able to compare this number to the maximum number of licenses available.

 

Is there any way to query/access this maximum number from apex code? As the number could potentially change if we buy more licenses so we don't want to hardcode it. If it's not possible to get this number in apex code, is there any way to access it using the API?

 

Thanks,


Dan

Message Edited by danwilkie on 06-26-2009 07:57 AM

I am struggling with this one. To keep this very simple lets say I have a List of strings. The length of this List is dynamic and can change. I would like to place this in a grid or table with four rows and basically fill the table left to right, top to bottom.

Lets say my list has 5 values. I want it to render like this:

[1][2][3][4]
[5]

if it has 10:

[1][2][3][4]
[5][6][7][8]
[9][10]

If it has 3:
[1][2][3]

This seems like it should be very simple but I can't figure this one out.

 

Thanks,

Jason

 

Message Edited by TehNrd on 10-23-2009 01:35 PM
  • October 23, 2009
  • Like
  • 0

I am trying to do a callout that logon's to a webservice and then returns an xml file.  I am trying to set the response header's content-type to be application-xml, but only see a setHeader method on the HttpRequest object.  

 

I am having a problem setting the Content-Type header with the below code.  When I check the Content-Type of the HttpResponse object, the value isn't 'application/xml' as I expected. 

 

Is this the correct approach?

 

 

Http http = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setHeader('Content-Type', 'application/xml'); req.setEndpoint('https://something./rest/clientauth/authenticate?account=xxx&password=xxx&source=xxx'); try { //Execute web service call here HTTPResponse res = http.send(req); //Helpful debug messages System.debug(res.toString()); System.debug('STATUS:'+res.getStatus()); System.debug('STATUS_CODE:'+res.getStatusCode()); System.debug('Content-Type:'+ res.getHeader('Content-Type')); } catch (System.CalloutException e) { system.debug('SKM-CalloutException occurred'); }

 

 

 

 

I am trying to execute the following code for recalling an approval process an ends up getting the following error

 

 

execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: INVALID_OPERATION, Illegal transition type:

 

 Approval.ProcessWorkItemRequest pwr = new Approval.ProcessWorkItemRequest();
       
List<ProcessInstance> procins = new List<ProcessInstance>([select Id from ProcessInstance where Status = 'Pending' and TargetObjectId = :objectId]);
// Retrieve the process work instance id associated to the process instance
            List<ProcessInstanceWorkitem>  workitem = new List<ProcessInstanceWorkitem>([select Id from ProcessInstanceWorkitem where ProcessInstanceId = :procins[0].id]);

            if ((workitem != null) && (workitem.size() > 0))
            {
                pwr.SetComments(statusToUpdate);

                pwr.setWorkItemId(workitem[0].id);
                pwr.setAction('Remove');
            
               
                // Execute process request
                Approval.ProcessResult pr = Approval.process(pwr);

}

Hello all. I'm having an issue with my Visualforce controller code and was wondering if anyone had any ideas for me.

The error I'm receiving is:
Code:
System.Exception: DML currently not allowed

Class.maExtension.save: line 18, column 13
External entry point
 
My controller code is:
Code:
public class maExtension {

 public scr__c scr {get; private set;}

 public maExtension() {
  scr = new scr__c();
 }

 public pagereference save() {
  scr.market_area__c = getmarket().id;
  system.debug('Market ID: ' + scr.market_area__c);
  system.debug('First Name: ' + scr.first_name__c);
  system.debug('Last Name: ' + scr.last_name__c);
  system.debug('Full Address: ' + scr.street_1__c + 
   ' ' + scr.street_2__c + ' ' + scr.city__c + 
   ' ' + scr.state__c + ' ' + scr.zip_code__c);
  try {
   insert scr;
   system.debug('Insert Successful');
  } catch(System.DmlException e) {
   system.debug(e.getDmlMessage(0));
  }
  return null;
 }

 ma__c market;

 public string getzip() {
  string zip = apexpages.currentpage().getparameters().get('zip');
  return zip;
 }

 public string getaddress() {
  string address = apexpages.currentpage().getparameters().get('street');
  return address;
 }

 public string getcity() {
  string city = getmarket().name;
  return city;
 }

 public string getstate() {
  string state = getmarket().primary_state__c;
  return state;
 }

 public boolean getmarketexists() {
  string zip = getzip();
  integer count = [select count() 
  from ma__c 
  where primary_zip_code__c = :zip 
  limit 1];
  boolean marketexists = count > 0 ? true : false;
  return marketexists;
 }

 public boolean getmarkethascoverage() {
  string zip = getzip();
  integer count = [select count() 
  from ma__c 
  where primary_zip_code__c = :zip 
  and (status__c = 'Partial Coverage' or status__c = 'Full Coverage') 
  limit 1];
  boolean getmarkethascoverage = count > 0 ? true : false;
  return getmarkethascoverage;
 }

 public ma__c getmarket() {
  if (getmarketexists() == true) {
   string zip = getzip();
   market = [select id, name, primary_zip_code__c, primary_state__c, status__c 
   from ma__c 
   where primary_zip_code__c = :zip 
   limit 1];
  } else {
   market = new ma__c();
  }
  return market;
 }

}
 
My Visualforce Page is:
Code:
 <apex:form id="scrform">
  <apex:inputfield id="scrfirstname" value="{!scr.first_name__c}" />First Name<br />
  <apex:inputfield id="scrlastname" value="{!scr.last_name__c}" />Last Name<br />
  <apex:inputfield id="scremail" value="{!scr.email_address__c}" />Email<br />
  <apex:inputfield id="scrstreet1" value="{!scr.street_1__c}" />Street Address 1<br />
  <apex:inputfield id="scrstreet2" value="{!scr.street_2__c}" />Street Address 2<br />
  <apex:inputfield id="scrcity" value="{!scr.city__c}" />City<br />
  <apex:inputfield id="scrstate" value="{!scr.state__c}" />State<br />
  <apex:inputfield id="scrzip" value="{!scr.zip_code__c}" />Zip Code<br />
  <apex:commandbutton action="{!save}" value="Sign Me Up" /><br />
 </apex:form>

When the "Sign Me Up" button invoking the save() method is clicked, I receive the exception. Any help would be greatly appreciated. Thanks!
  • October 21, 2008
  • Like
  • 0