• SirTrav
  • NEWBIE
  • 75 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 15
    Replies
I am working on adding a Visualforce page to the Opportunity layout.  Whenever I add any Visualforce page to the opportunity layout it causes the Opportunity to refresh over and over again.  I have simplified the page so that it is just:
<apex:page standardController="Opportunity">
</apex:page>
I created a new Opportunity page layout without copying an existing layout and added just the above Visualforce page to the layout and got the same result.  Any ideas on what would be cuasing this?
I have a Quote approval and have a visualforce email template that is being used as the approval email.  I have a user that would like to see the actual Quote PDF that goes out to the customer but would still like to be able to reply to the email to approve of reject the approval.   I am not sure if this is possible or how I would do it.  Can anyone think of a way using any of the Salesforce features like apex, or inbound email that I could send the approval email out with the actual PDF from the quote attached to it? 
I have a wrapper class that has a number of objects in it.  I then have a list of that class that is displayed on a visualforce page.  what I want to do is take the initial list and copy it and put it in a second list.  Then I want to be able to edit the first list without the second list being changed.  Here is what the code looks like the one below but I have shortened the code by removing some standard stuff and puting ...... in its place.  what I am trying to do is leave the original list in place on the visualforce page to be edited and added back to the second list with slightly different answers.  The problem is that when the original list is changed it changes the second list. 

public void runAtStart(){
     MwList = new list<MyWrapper>();
     OpportunityLineItem o = new OpportunityLineItem();
     o.opportunityid = .........
     MyWrapper mw = new MyWrapper();
     mw.oli = .......
     MwList.add(mw);   
}

public class MyWrapper{
     public opportunitylineitem oli {get;set;}
     public string s {get;set;}
     public integer i {get;set;}
}

public list<MyWrapper> MwList {get;set;}
public list<MyWrapper> WrapperList2 {get;set;}

public void ToSecondList(){
     if(WrapperList2 == null){
          WrapperList2 = new list<MyWrapper>();
     }
     for(MyWrapper m : MwList){
          MyWrapper w = new MyWrapper();
          w = m.clone();
          WrapperList2.add(w);
     }
}

}


I want to remove the Global Search box from the communities header.  I know how to over ride the default header with an html code, but what I don't know if how on that html code to have the Logout button that is usually there.  So the standard community header has the logo then the global search and then the logout button.  I just want to remove the global search.  Is there a way to do this? 
I am trying to do a soql query using database.query so that I can dynamically build the search parameters.  the problem I am having is with the following portion:
qry3 = qry2 + 'where name like :%' + sobj.name + '% OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I put it in this way I get the error : no viable alternative at character '%'
I have tried:
qry3 = qry2 + 'where name like :\'%' + sobj.name + '%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I do it this way I get the error: unexpected token: '%test test%'
and I have tried it this way: 
qry3 = qry2 + 'where name like :\'%\'' + sobj.name + '\'%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
and I get the error: unexpected token: '%'

Any idea what I need to change to get the like statement to work?

I have a visualforce page and want to track the IP address of the user who accesses it.  ApexPages.currentPage().getHeaders().get('True-Client-IP'); and ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP'); but the X-Salesforce-SIP only returns the Salesforce IP not the users public IP.  the True-Client-IP comes back as null.  I had this setup once using Javascript but I don't remember the code and lost where I had it saved.  Can anyone help with a way to get the IP address of the person accessing the visualforce page?

I have a trigger that populates a number of lookup fields when an item is inserted into salesforce.  That trigger calls a class that runs the logic in batch apex.  The problem I have is that when we import more than 1000 records using dataloader.io it imports them in sets of 200 records each.  The end result is that I get an error that says that I have "Attempted to schedule too many concurrent batch jobs in this org".  Is there any way to get around this?

  • September 16, 2013
  • Like
  • 0

When talking to another developer today we came across a question that we can't find the answer to so I was hoping someone here knew the answer.  I know that you can create a visualforce page with more than one extension.  My questions are:

1. Why would you use more than one?

2. If you have more that one in what order does visualforce look for your method?

3. What happens if you have a method with the same name on different extensions?

  • September 06, 2013
  • Like
  • 2

I have an input field on a visualforce page called y1supportPackage.  on the extension I have this field in an if statement.  I have tried this statement two different ways.

1. if(string.isNotBlank(y1supportPackage)) { code here}

2. if(y1supportPackage != null){code here}

 

What is throwing me off is that it is saying the field is not blank when it is.  I have added 2 debugs just above the if statement.  So here is what it looks like right now

system.debug(logginglevel.info, '*****y1supportPackage='+y1supportPackage);
        system.debug(logginglevel.info, '*****string.isNotBlank(y1supportPackage)='+string.isNotBlank(y1supportPackage));
        if(string.isNotBlank(y1supportPackage)) {

 Here is what my debug log is saying:

18:38:00.227 (227910000)|USER_DEBUG|[1333]|INFO|*****y1supportPackage=null
18:38:00.227 (227918000)|SYSTEM_METHOD_EXIT|[1333]|System.debug(APEX_OBJECT, ANY)
18:38:00.227 (227934000)|METHOD_ENTRY|[1334]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.227 (227951000)|METHOD_EXIT|[1334]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.227 (227969000)|SYSTEM_METHOD_ENTRY|[1334]|String.isNotBlank(String)
18:38:00.227 (227979000)|SYSTEM_METHOD_EXIT|[1334]|String.isNotBlank(String)
18:38:00.227 (227988000)|SYSTEM_METHOD_ENTRY|[1334]|String.valueOf(Object)
18:38:00.227 (227997000)|SYSTEM_METHOD_EXIT|[1334]|String.valueOf(Object)
18:38:00.228 (228008000)|SYSTEM_METHOD_ENTRY|[1334]|System.debug(APEX_OBJECT, ANY)
18:38:00.228 (228023000)|USER_DEBUG|[1334]|INFO|*****string.isNotBlank(y1supportPackage)=true
18:38:00.228 (228031000)|SYSTEM_METHOD_EXIT|[1334]|System.debug(APEX_OBJECT, ANY)
18:38:00.228 (228040000)|METHOD_ENTRY|[1335]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.228 (228056000)|METHOD_EXIT|[1335]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.228 (228066000)|SYSTEM_METHOD_ENTRY|[1335]|String.isNotBlank(String)
18:38:00.228 (228074000)|SYSTEM_METHOD_EXIT|[1335]|String.isNotBlank(String)
18:38:00.228 (228088000)|METHOD_ENTRY|[1336]|01pK0000000AbBG|addProductsExt.__sfdc_supportPackage()
18:38:00.228 (228103000)|METHOD_EXIT|[1336]|01pK0000000AbBG|addProductsExt.__sfdc_supportPackage()
18:38:00.228 (228113000)|SYSTEM_METHOD_ENTRY|[1336]|String.valueOf(Object)
18:38:00.228 (228120000)|SYSTEM_METHOD_EXIT|[1336]|String.valueOf(Object)
18:38:00.228 (228131000)|SYSTEM_METHOD_ENTRY|[1336]|System.debug(APEX_OBJECT, ANY)

 

You will notice that it says y1supportPackage=null and then the next line of code says that string.isNotBlank(y1supportPackage)=true.

 

What am I missing?  Why when the field is null is the if statement saying that it is not equal to null?

I am attempting to connect to a program called Fishbowl.  It runs a server off of a computer.  When I make the connection to it I get an error that says "incoming message length invalid, message length 1347375956 bytes"  I can take the xml out of my code and put it into their connection testing tool and it works.  here is my code:

public void connect(){
    HttpRequest req = new HttpRequest();
    req.setEndPoint('http://11.111.111.111:28192');
    
    
    DOM.Document doc = new DOM.Document();
        Dom.XmlNode envelope = doc.createRootElement('FbiXml',null,null);
            dom.XmlNode header2 = envelope.addChildElement('Ticket', null, null);
                dom.XmlNode header3 = header2.addChildElement('Key', null, null);
            dom.XmlNode header1 = envelope.addChildElement('FbiMsgsRq', null, null);
            dom.XmlNode body = header1.addChildElement('LoginRq', null, null);
                body.addChildElement('IAID', null, null).addTextNode('123456');
                body.addChildElement('IAName', null, null).addTextNode('FishbowlKyazmaTest');
                body.addChildElement('IADescription', null, null).addTextNode('his is a test of the connection');
                body.addChildElement('UserName', null, null).addTextNode('admin');
                body.addChildElement('UserPassword', null, null).addTextNode('ISMvKXpXpadDiUoOSoAfww==');
    req.setCompressed(true);
    req.setBodydocument(doc);
    req.setMethod('POST');
    Http http = new Http();
    system.debug(logginglevel.info, '*****req='+req);
    HTTPResponse res = http.send(req);
    System.debug(res.getBody());
}

 Any idea why it would be receiving such a large message?  

Here is the scenario:  I have a lead that has a lookup to another lead.  I want when the first lead is converted to automatically convert the second lead.  I have created a trigger to convert the second lead but I keep getting an error that says:  " first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [] (System Code)"

Here is my trigger:

 

trigger owner2LeadConvert on Lead (after update) {
	for (lead l : trigger.new) {
		if (l.isconverted == true && l.Owner_2__c != null) {
			system.debug(logginglevel.info, '*****');
			Database.LeadConvert lc = new database.LeadConvert();
			lc.setLeadId(l.Owner_2__c);

			LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
			lc.setConvertedStatus(convertStatus.MasterLabel);

			Database.LeadConvertResult lcr = Database.convertLead(lc);
			System.assert(lcr.isSuccess());
		}
	}
}

 I checked the debugs and it is running my trigger and it is when it tries to convert the second lead that it has the error.  I have tried about the same thing off of the account and get the exact same error.  They are being converted to person accounts if that matters.

I am trying to make a call out to a webconnection to an external service.  I have a program that will test to make sure the service is working.  In that program if I put http://111.222.3.44 it cannot connect to my webservice, but if I put 111.222.3.44 it can connect to my service.  In salesforce I have tried going 

    HttpRequest req = new HttpRequest();
    req.setEndPoint('111.222.3.444:12345');

 What I get is an error that says System.CalloutException: no protocol:111.222.3.444:12345  If I put the http:// on there it just times out.  Any idea how to make salesforce not require the http or is there a different callout method?

I am trying to connect Salesforce to a fishbowl server.  Unfortunately I have very little expirience with web services.  I have built an apex class that would make the callout but it times out.  I know the port is open and the ip are good because I can connect with fishbowl into the server from an outside computer.  Any help or advise would be appreciated.  If you want to look at fishbowl's docs here they are: 

http://www.fishbowlinventory.com/files/release/2012-08-16/fi-2012.7.exe

Here is my code I have changed the IP address to a random one.  The port is the actual port that fishbowl uses.

public with sharing class fishExt {


public void connect(){
	HttpRequest req = new HttpRequest();
	req.setEndPoint('http://11.111.111.111:28192');
	String xml = '<FbiXml><Ticket/><FbiMsgsRq><LoginRq><IAID>123456</IAID><IAName>FishbowlKyazmaTest</IAName><IADescription>This is a test of the connection</IADescription><UserName>admin</UserName><UserPassword>' + EncodingUtil.base64Encode(blob.valueof('admin')) + '</UserPassword></LoginRq></FbiMsgsRq></FbiXml>';
	req.setBody(xml);
	req.setMethod('GET');
	req.setTimeout(120000);
	
	Http http = new Http();
    HTTPResponse res = http.send(req);
    System.debug(res.getBody());
}



}

 

 

I have created a button to recall an approval process.  Here is my code:

    public pagereference TotalRecal(){
        o = [select Needs_Approval__c, recordtypeid from opportunity where id = :apexpages.currentpage().getparameters().get('id')];
        pi = [select id from ProcessInstance where TargetObjectId = :o.id];
        if (pi.isempty()) {
            o.StageName = 'Negotiations';
            o.Needs_Approval__c = true;
        }
        else{
            for (ProcessInstance p : pi) {
                piID.add(p.id);
            }
            ProcessInstanceWorkitem[] piwi = [select id from ProcessInstanceWorkitem where ProcessInstanceId in :piID];
            for (ProcessInstanceWorkitem p : piwi) {
                approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
                pwr.setWorkitemId(p.id);
                pwr.setAction('Removed');
                pwr.setComments(com);
                Approval.ProcessResult result =  Approval.process(pwr);
            }
            o.StageName = 'Negotiations';
            o.Needs_Approval__c = true;
        }
        update o;
        pagereference page = new pagereference('/'+o.id);
        return page;
    }

 It works correctly in the sandbox but when I try to move it to production I get this error: 

 

Failure Message: "System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.ApprovalRecalExt.TotalRecal: line 27, column 1 Class.ApprovalRecalExtTest.ApprovalRecalExtTest: line 18, column 1"

 

Here is my test class: 

@istest
public class ApprovalRecalExtTest{
public static testmethod void ApprovalRecalExtTest(){
	account a = new account(name='test');
	insert a;
	opportunity o = new opportunity(name='testopp', account=a, stagename='approved', closedate=date.today());
	insert o;
	pagereference page1 = new pagereference('/apex/approvalrecal?id='+o.id);
    test.setcurrentpage(page1);
    ApprovalRecalExt ar = new ApprovalRecalExt();
    ar.TotalRecal();
    ar.neverMind();
    Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
    psr.setObjectId(o.id);
    Approval.ProcessResult result = Approval.process(psr);
    test.setcurrentpage(page1);
    ApprovalRecalExt ar1 = new ApprovalRecalExt();
    ar1.TotalRecal();
    
}
}

 I can't figure out why it would work in sandbox but not production.  Thanks for any help you can give me.  

 

I have salesforce crm content setup and have gone through the info on this page https://na3.salesforce.com/help/doc/en/partner_portal_content.htm.  in the portal the Libraries tab shows up and when you click on it you get salesforce.com/sfc/#workspaces but the page is just a blank white page.  No header or sidebar or anything.  Any idea why it is doing this?

I have a class that makes some updates based on OpportunityPartner.  I am working on the test method but am not sure how to create an OpportunityPartner to use for the test.  When I try to insert an OpportunityPartner it says that DML is not allowed which makes sense because OpportunityPartner is a read only object.  So what I want to know is how do I run a test method when my class relies on at least 1 OpportunityPartner being created? 

I want to remove the Global Search box from the communities header.  I know how to over ride the default header with an html code, but what I don't know if how on that html code to have the Logout button that is usually there.  So the standard community header has the logo then the global search and then the logout button.  I just want to remove the global search.  Is there a way to do this? 

When talking to another developer today we came across a question that we can't find the answer to so I was hoping someone here knew the answer.  I know that you can create a visualforce page with more than one extension.  My questions are:

1. Why would you use more than one?

2. If you have more that one in what order does visualforce look for your method?

3. What happens if you have a method with the same name on different extensions?

  • September 06, 2013
  • Like
  • 2
I am working on adding a Visualforce page to the Opportunity layout.  Whenever I add any Visualforce page to the opportunity layout it causes the Opportunity to refresh over and over again.  I have simplified the page so that it is just:
<apex:page standardController="Opportunity">
</apex:page>
I created a new Opportunity page layout without copying an existing layout and added just the above Visualforce page to the layout and got the same result.  Any ideas on what would be cuasing this?
I have a wrapper class that has a number of objects in it.  I then have a list of that class that is displayed on a visualforce page.  what I want to do is take the initial list and copy it and put it in a second list.  Then I want to be able to edit the first list without the second list being changed.  Here is what the code looks like the one below but I have shortened the code by removing some standard stuff and puting ...... in its place.  what I am trying to do is leave the original list in place on the visualforce page to be edited and added back to the second list with slightly different answers.  The problem is that when the original list is changed it changes the second list. 

public void runAtStart(){
     MwList = new list<MyWrapper>();
     OpportunityLineItem o = new OpportunityLineItem();
     o.opportunityid = .........
     MyWrapper mw = new MyWrapper();
     mw.oli = .......
     MwList.add(mw);   
}

public class MyWrapper{
     public opportunitylineitem oli {get;set;}
     public string s {get;set;}
     public integer i {get;set;}
}

public list<MyWrapper> MwList {get;set;}
public list<MyWrapper> WrapperList2 {get;set;}

public void ToSecondList(){
     if(WrapperList2 == null){
          WrapperList2 = new list<MyWrapper>();
     }
     for(MyWrapper m : MwList){
          MyWrapper w = new MyWrapper();
          w = m.clone();
          WrapperList2.add(w);
     }
}

}


I am trying to do a soql query using database.query so that I can dynamically build the search parameters.  the problem I am having is with the following portion:
qry3 = qry2 + 'where name like :%' + sobj.name + '% OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I put it in this way I get the error : no viable alternative at character '%'
I have tried:
qry3 = qry2 + 'where name like :\'%' + sobj.name + '%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
when I do it this way I get the error: unexpected token: '%test test%'
and I have tried it this way: 
qry3 = qry2 + 'where name like :\'%\'' + sobj.name + '\'%\' OR Account__c = :' + sobj.Account__c + ' OR Opportunity__c = :' + sobj.Opportunity__c + ' limit 50';
and I get the error: unexpected token: '%'

Any idea what I need to change to get the like statement to work?

I have a visualforce page and want to track the IP address of the user who accesses it.  ApexPages.currentPage().getHeaders().get('True-Client-IP'); and ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP'); but the X-Salesforce-SIP only returns the Salesforce IP not the users public IP.  the True-Client-IP comes back as null.  I had this setup once using Javascript but I don't remember the code and lost where I had it saved.  Can anyone help with a way to get the IP address of the person accessing the visualforce page?

I have a trigger that populates a number of lookup fields when an item is inserted into salesforce.  That trigger calls a class that runs the logic in batch apex.  The problem I have is that when we import more than 1000 records using dataloader.io it imports them in sets of 200 records each.  The end result is that I get an error that says that I have "Attempted to schedule too many concurrent batch jobs in this org".  Is there any way to get around this?

  • September 16, 2013
  • Like
  • 0

When talking to another developer today we came across a question that we can't find the answer to so I was hoping someone here knew the answer.  I know that you can create a visualforce page with more than one extension.  My questions are:

1. Why would you use more than one?

2. If you have more that one in what order does visualforce look for your method?

3. What happens if you have a method with the same name on different extensions?

  • September 06, 2013
  • Like
  • 2

I have an input field on a visualforce page called y1supportPackage.  on the extension I have this field in an if statement.  I have tried this statement two different ways.

1. if(string.isNotBlank(y1supportPackage)) { code here}

2. if(y1supportPackage != null){code here}

 

What is throwing me off is that it is saying the field is not blank when it is.  I have added 2 debugs just above the if statement.  So here is what it looks like right now

system.debug(logginglevel.info, '*****y1supportPackage='+y1supportPackage);
        system.debug(logginglevel.info, '*****string.isNotBlank(y1supportPackage)='+string.isNotBlank(y1supportPackage));
        if(string.isNotBlank(y1supportPackage)) {

 Here is what my debug log is saying:

18:38:00.227 (227910000)|USER_DEBUG|[1333]|INFO|*****y1supportPackage=null
18:38:00.227 (227918000)|SYSTEM_METHOD_EXIT|[1333]|System.debug(APEX_OBJECT, ANY)
18:38:00.227 (227934000)|METHOD_ENTRY|[1334]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.227 (227951000)|METHOD_EXIT|[1334]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.227 (227969000)|SYSTEM_METHOD_ENTRY|[1334]|String.isNotBlank(String)
18:38:00.227 (227979000)|SYSTEM_METHOD_EXIT|[1334]|String.isNotBlank(String)
18:38:00.227 (227988000)|SYSTEM_METHOD_ENTRY|[1334]|String.valueOf(Object)
18:38:00.227 (227997000)|SYSTEM_METHOD_EXIT|[1334]|String.valueOf(Object)
18:38:00.228 (228008000)|SYSTEM_METHOD_ENTRY|[1334]|System.debug(APEX_OBJECT, ANY)
18:38:00.228 (228023000)|USER_DEBUG|[1334]|INFO|*****string.isNotBlank(y1supportPackage)=true
18:38:00.228 (228031000)|SYSTEM_METHOD_EXIT|[1334]|System.debug(APEX_OBJECT, ANY)
18:38:00.228 (228040000)|METHOD_ENTRY|[1335]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.228 (228056000)|METHOD_EXIT|[1335]|01pK0000000AbBG|addProductsExt.__sfdc_y1supportPackage()
18:38:00.228 (228066000)|SYSTEM_METHOD_ENTRY|[1335]|String.isNotBlank(String)
18:38:00.228 (228074000)|SYSTEM_METHOD_EXIT|[1335]|String.isNotBlank(String)
18:38:00.228 (228088000)|METHOD_ENTRY|[1336]|01pK0000000AbBG|addProductsExt.__sfdc_supportPackage()
18:38:00.228 (228103000)|METHOD_EXIT|[1336]|01pK0000000AbBG|addProductsExt.__sfdc_supportPackage()
18:38:00.228 (228113000)|SYSTEM_METHOD_ENTRY|[1336]|String.valueOf(Object)
18:38:00.228 (228120000)|SYSTEM_METHOD_EXIT|[1336]|String.valueOf(Object)
18:38:00.228 (228131000)|SYSTEM_METHOD_ENTRY|[1336]|System.debug(APEX_OBJECT, ANY)

 

You will notice that it says y1supportPackage=null and then the next line of code says that string.isNotBlank(y1supportPackage)=true.

 

What am I missing?  Why when the field is null is the if statement saying that it is not equal to null?

Here is the scenario:  I have a lead that has a lookup to another lead.  I want when the first lead is converted to automatically convert the second lead.  I have created a trigger to convert the second lead but I keep getting an error that says:  " first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [] (System Code)"

Here is my trigger:

 

trigger owner2LeadConvert on Lead (after update) {
	for (lead l : trigger.new) {
		if (l.isconverted == true && l.Owner_2__c != null) {
			system.debug(logginglevel.info, '*****');
			Database.LeadConvert lc = new database.LeadConvert();
			lc.setLeadId(l.Owner_2__c);

			LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
			lc.setConvertedStatus(convertStatus.MasterLabel);

			Database.LeadConvertResult lcr = Database.convertLead(lc);
			System.assert(lcr.isSuccess());
		}
	}
}

 I checked the debugs and it is running my trigger and it is when it tries to convert the second lead that it has the error.  I have tried about the same thing off of the account and get the exact same error.  They are being converted to person accounts if that matters.

I am trying to connect Salesforce to a fishbowl server.  Unfortunately I have very little expirience with web services.  I have built an apex class that would make the callout but it times out.  I know the port is open and the ip are good because I can connect with fishbowl into the server from an outside computer.  Any help or advise would be appreciated.  If you want to look at fishbowl's docs here they are: 

http://www.fishbowlinventory.com/files/release/2012-08-16/fi-2012.7.exe

Here is my code I have changed the IP address to a random one.  The port is the actual port that fishbowl uses.

public with sharing class fishExt {


public void connect(){
	HttpRequest req = new HttpRequest();
	req.setEndPoint('http://11.111.111.111:28192');
	String xml = '<FbiXml><Ticket/><FbiMsgsRq><LoginRq><IAID>123456</IAID><IAName>FishbowlKyazmaTest</IAName><IADescription>This is a test of the connection</IADescription><UserName>admin</UserName><UserPassword>' + EncodingUtil.base64Encode(blob.valueof('admin')) + '</UserPassword></LoginRq></FbiMsgsRq></FbiXml>';
	req.setBody(xml);
	req.setMethod('GET');
	req.setTimeout(120000);
	
	Http http = new Http();
    HTTPResponse res = http.send(req);
    System.debug(res.getBody());
}



}

 

 

I have created a button to recall an approval process.  Here is my code:

    public pagereference TotalRecal(){
        o = [select Needs_Approval__c, recordtypeid from opportunity where id = :apexpages.currentpage().getparameters().get('id')];
        pi = [select id from ProcessInstance where TargetObjectId = :o.id];
        if (pi.isempty()) {
            o.StageName = 'Negotiations';
            o.Needs_Approval__c = true;
        }
        else{
            for (ProcessInstance p : pi) {
                piID.add(p.id);
            }
            ProcessInstanceWorkitem[] piwi = [select id from ProcessInstanceWorkitem where ProcessInstanceId in :piID];
            for (ProcessInstanceWorkitem p : piwi) {
                approval.ProcessWorkitemRequest pwr = new Approval.ProcessWorkitemRequest();
                pwr.setWorkitemId(p.id);
                pwr.setAction('Removed');
                pwr.setComments(com);
                Approval.ProcessResult result =  Approval.process(pwr);
            }
            o.StageName = 'Negotiations';
            o.Needs_Approval__c = true;
        }
        update o;
        pagereference page = new pagereference('/'+o.id);
        return page;
    }

 It works correctly in the sandbox but when I try to move it to production I get this error: 

 

Failure Message: "System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.ApprovalRecalExt.TotalRecal: line 27, column 1 Class.ApprovalRecalExtTest.ApprovalRecalExtTest: line 18, column 1"

 

Here is my test class: 

@istest
public class ApprovalRecalExtTest{
public static testmethod void ApprovalRecalExtTest(){
	account a = new account(name='test');
	insert a;
	opportunity o = new opportunity(name='testopp', account=a, stagename='approved', closedate=date.today());
	insert o;
	pagereference page1 = new pagereference('/apex/approvalrecal?id='+o.id);
    test.setcurrentpage(page1);
    ApprovalRecalExt ar = new ApprovalRecalExt();
    ar.TotalRecal();
    ar.neverMind();
    Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
    psr.setObjectId(o.id);
    Approval.ProcessResult result = Approval.process(psr);
    test.setcurrentpage(page1);
    ApprovalRecalExt ar1 = new ApprovalRecalExt();
    ar1.TotalRecal();
    
}
}

 I can't figure out why it would work in sandbox but not production.  Thanks for any help you can give me.  

 

I have a class that makes some updates based on OpportunityPartner.  I am working on the test method but am not sure how to create an OpportunityPartner to use for the test.  When I try to insert an OpportunityPartner it says that DML is not allowed which makes sense because OpportunityPartner is a read only object.  So what I want to know is how do I run a test method when my class relies on at least 1 OpportunityPartner being created?