• falfadli
  • NEWBIE
  • 50 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 13
    Replies
Please help in resolving errors like :

INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call:

This is related to a similar post I put up recently, but wanted to revisit.I have an Ajax querythat will always return just one record. However, I am having trouble accessing the results without using the for loop. There is something wrong with my code that does not have the for loop. Can anyone tell me what is wrong?

 

////This works  and returns a value, but it bothers me because I am using a for loop although there is only one record

sicQuery = "Select SIC_Code__r.Name, SIC_Code__c From Opportunity WHERE Id='" + opptyId +"' LIMIT 1";

result = sforce.connection.query(sicQuery);
records = result.getArray("records");
for (var i=0; i< records.length; i++) {
  var record = records[i];
  var sic  = record.SIC_Code__r.Name;
}

alert(sic);

 

 

////This does not work and gives me a "records.SIC_Code__r is undefined"error

sicQuery = "Select SIC_Code__r.Name, SIC_Code__c From Opportunity WHERE Id='" + opptyId +"' LIMIT 1";

result = sforce.connection.query(sicQuery);
records = result.getArray("records");

if (records.length=1) { 

  var sic  = records.SIC_Code__r.Name;
}
alert(sic);

 

 

Any help would be greatly appreciated!

I am working on developing an integration with PayPal. They have a web service API and I wanted to utilize some paypal SOAP libraries. Can I import libraries similar as you would in java?

 

I am trying to avoid building a SOAP message manually and the wsdl2apex class generator does not support the wsdl because of multiple port bindings and imports within the wsdl. And I do not want to hack the wsdl.  

 

Any advice on how to do this would be appreciated so I can set values on the objects and send the request via object method calls....If I cannot, backup plan is to use the HTTP Request and Response classes

 

 

import com.paypal.sdk.profiles.APIProfile;
import com.paypal.sdk.profiles.ProfileFactory;
import com.paypal.sdk.services.CallerServices;
import com.paypal.soap.api.AddressType;
import com.paypal.soap.api.BasicAmountType;
import com.paypal.soap.api.CountryCodeType;
import com.paypal.soap.api.CreditCardDetailsType;
import com.paypal.soap.api.CreditCardTypeType;
import com.paypal.soap.api.CurrencyCodeType;
import com.paypal.soap.api.DoDirectPaymentRequestDetailsType;
import com.paypal.soap.api.DoDirectPaymentRequestType;
import com.paypal.soap.api.DoDirectPaymentResponseType;
import com.paypal.soap.api.PayerInfoType;
import com.paypal.soap.api.PaymentActionCodeType;
import com.paypal.soap.api.PaymentDetailsType;
import com.paypal.soap.api.PersonNameType;
//Ideally I would like to do something like this.                                                                                                                                              PayerInfoType payer                   PayerInfoType() payer= new PayerInfoType();
PersonNameType name = new PersonNameType();
name.setFirstName(buyerFirstName);
name.setLastName(buyerLastName);
payer.setPayerName(name);
payer.setPayerCountry(CountryCodeType.US);
payer.setAddress(shipTo);

Message Edited by falfadli on 05-04-2009 11:14 AM

I am trying to return some information for just the PRIMARY contact on a given account. I think I can do this in one query.

 

However the query below returns me all the contacts (primary and non primary). Can anyone tell me whats wrong with my SOQL and how I should go about just returning the details of the primary contact? 

 

Select c.Phone, c.LastName, c.FirstName, (Select AccountId, ContactId From AccountContactRoles WHERE IsPrimary =true) From Contact c

 

Thanks

I am using the Ajax toolkit for the first time and had a simple question.

 

I have a query that looks like this.

 

userEmailQuery = "Select Email From User WHERE id ="+"'"+userId+"' ";
result = sforce.connection.query(userEmailQuery);

 

which results in a string that looks like this....{done:'true', queryLocator:null, records:{type:'User', Id:null, Email:'me@mycompany.com', }, size:'1', }

 

I am having trouble just getting my Email element using the syntax below. What is the proper way to obtain the value of the Email from the above result.

 

result.Email;
result.get("Email");

 

Thanks

Hi all,

 

I am creating a custom button on a related list off the Opportunity object. The button is to open the edit fields of a new related object and pass in a few default fields. 

 

The code below works, but I want to try and avoid hard coding the  '/a06/e?'string while building the URL. It does not appear to be part of the 'window.location.host'.....any advice how to get this dynamically would be appreciated.

 

Thanks

 

 

//define fields to obtain from Opportunity to be sent to the case edit page
var opptyName="{!Opportunity.Name}";
var oppty ="{!Opportunity.Id}";
var salesRep = "{!Opportunity.OwnerFullName}";
var leadUw = "{!Opportunity.Lead_UW__c}";

//define default fields to set for redirect
var opptyField = "CF00N300000039AI6="+opptyName;
var salesRepField ="&CF00N300000039QwI="+salesRep;
var leadUwField ="&CF00N300000039AIY="+leadUw;

top.location.replace("https://"+window.location.host+"/a06/e?"+opptyField+salesRepField+leadUwField+"&retURL="+oppty);
 

The following code compiles but causes a System.type exception - invalid date/time during runtime. I The first and second lines appear to fail. I am trying to get a dat from the db( aPgCase.Effective_End_Date__c) and add 1 year. Same for the second line but add one day. Can someone tell me what I am doing wrong?

 

Thanks

 

DateTime newEffectiveEndDate =  DateTime.valueOf(aPgCase.Effective_End_Date__c).addYears(1);
DateTime newEffectiveStartDate =  DateTime.valueOf(aPgCase.Effective_Start_Date__c).addDays(1);
Date newEffectiveEndDay = Date.valueOf(newEffectiveEndDate);
Date newEffectiveStartDay = Date.valueOf(newEffectiveStartDate);

Hi all,

 

easy question.....I have writtent the following web service...

 

global class UwCheckList {

 

webService static boolean getRegion(id opportunityId){

 

boolean oppExistInCw = false;

//query UW_CheckList Object to search for related opportunity

UW_Checklist__c aUW_Checklist = [Select Id, UW_Activity_Status__c from UW_checklist__c where Opportunity__c= :opportunityId LIMIT 1];

 if(aUW_Checklist!=null) {

//update status field

aUW_Checklist.UW_Activity_Status__c = 'Ready to Rate'; update aUW_Checklist;

oppExistInCw = true;

return oppExistInCw;

}

else {

return oppExistInCw;

}

 

 

}

}

 

I was trying to find some simple example syntax that I could use in the Execute Anonymous area of the IDE to test htis out. Can anyone provide an example I could reference?

 

Thanks

This is related to a similar post I put up recently, but wanted to revisit.I have an Ajax querythat will always return just one record. However, I am having trouble accessing the results without using the for loop. There is something wrong with my code that does not have the for loop. Can anyone tell me what is wrong?

 

////This works  and returns a value, but it bothers me because I am using a for loop although there is only one record

sicQuery = "Select SIC_Code__r.Name, SIC_Code__c From Opportunity WHERE Id='" + opptyId +"' LIMIT 1";

result = sforce.connection.query(sicQuery);
records = result.getArray("records");
for (var i=0; i< records.length; i++) {
  var record = records[i];
  var sic  = record.SIC_Code__r.Name;
}

alert(sic);

 

 

////This does not work and gives me a "records.SIC_Code__r is undefined"error

sicQuery = "Select SIC_Code__r.Name, SIC_Code__c From Opportunity WHERE Id='" + opptyId +"' LIMIT 1";

result = sforce.connection.query(sicQuery);
records = result.getArray("records");

if (records.length=1) { 

  var sic  = records.SIC_Code__r.Name;
}
alert(sic);

 

 

Any help would be greatly appreciated!

I am trying to return some information for just the PRIMARY contact on a given account. I think I can do this in one query.

 

However the query below returns me all the contacts (primary and non primary). Can anyone tell me whats wrong with my SOQL and how I should go about just returning the details of the primary contact? 

 

Select c.Phone, c.LastName, c.FirstName, (Select AccountId, ContactId From AccountContactRoles WHERE IsPrimary =true) From Contact c

 

Thanks

I am using the Ajax toolkit for the first time and had a simple question.

 

I have a query that looks like this.

 

userEmailQuery = "Select Email From User WHERE id ="+"'"+userId+"' ";
result = sforce.connection.query(userEmailQuery);

 

which results in a string that looks like this....{done:'true', queryLocator:null, records:{type:'User', Id:null, Email:'me@mycompany.com', }, size:'1', }

 

I am having trouble just getting my Email element using the syntax below. What is the proper way to obtain the value of the Email from the above result.

 

result.Email;
result.get("Email");

 

Thanks

I have a Cronkit job scheduled to run every night, and it has been doing fine for weeks, but last night 4 of the scheduled jobs did not run, and gives a message :

FutureRequests Request Limit exceeded.

 

What does this mean?

 
  • April 21, 2009
  • Like
  • 0

There are some opportunities with email address and email message.

I want to send to email addresses in these opportunities every 3 days.

I created a custom field in opportunity, which is MOD(today()-createDate(), 3).

The workflow is created as sending email when this mod field is 0.

 

But this workflow only run when the opportunity is created or edit. I can not edit every opportuinty every day. Can I make the workflow run, even if opportunity is not edited?

  • April 20, 2009
  • Like
  • 0

The following code compiles but causes a System.type exception - invalid date/time during runtime. I The first and second lines appear to fail. I am trying to get a dat from the db( aPgCase.Effective_End_Date__c) and add 1 year. Same for the second line but add one day. Can someone tell me what I am doing wrong?

 

Thanks

 

DateTime newEffectiveEndDate =  DateTime.valueOf(aPgCase.Effective_End_Date__c).addYears(1);
DateTime newEffectiveStartDate =  DateTime.valueOf(aPgCase.Effective_Start_Date__c).addDays(1);
Date newEffectiveEndDay = Date.valueOf(newEffectiveEndDate);
Date newEffectiveStartDay = Date.valueOf(newEffectiveStartDate);

I'm learning to write apex code for calling out to external webservices. I started out with strikeIrons zipcode lookup. I'm new to webservices, so please help me out. Is this how I should go abt doing it?

1. Get WSDL. Generate apex.(done)

2. Created county__c field in account sObject(done)

3. Write before insert, before update trigger that passes the zipcode to CountyLookupClass.(done)

4. CountyLookupClass calls the @future webservice, passes the authentication parameters(username,password) and also the zipcode. 

5. StrikeIron authenticates. Returns county. 

6. Need to map the returned county name to Account.County__c field, so that it is added/inserted to the force.com database. 

 

Am I right? Here is the trigger

 

trigger CountyLookupTrigger on Account (before insert, before update) {

for(Account a: Trigger.new)
CountyLookupClass.CallWS(a);

}

 

 Apex class in invoke webservice

 

public class CountyLookupClass {


@future(callout=true)
public static void CallWS(String zcode){
//pass zipcode to ZipINfo
//get info
//parse to county__c
//create the stub
ZipLookup.ZipInfoSoap zipl = new ZipLookup.ZipInfoSoap();

//instantiate and setup authentication information

zipl.LicenseInfo = new ZipUser.LicenseInfo();
zipl.LicenseInfo.RegisteredUser = new ZipUser.RegisteredUser();
zipl.LicenseInfo.RegisteredUser.UserID = 'withoutme@gmail.com';
zipl.LicenseInfo.RegisteredUser.Password='******';
//call web service
ZipLookup.SIWsOutputOfZipInfoResult zz = zipl.GetCityState('94131');
String c = zz.ServiceResult.Code;
System.debug('Codeis' + c);
//ZipLookup.ZipInfoResult z = zipl.GetCityState('85281').;

}}

 

 

 

 

How do I test this? Am I doing it right?

 

 

 

And the apex from wsdl2apex.wsdl fom http://www.strikeiron.com/productdetail.aspx?p=436

 

 


 

Message Edited by vviyer on 04-09-2009 10:33 PM
Message Edited by vviyer on 04-09-2009 11:44 PM
Message Edited by vviyer on 04-09-2009 11:45 PM
  • April 09, 2009
  • Like
  • 0

Hi all,

 

easy question.....I have writtent the following web service...

 

global class UwCheckList {

 

webService static boolean getRegion(id opportunityId){

 

boolean oppExistInCw = false;

//query UW_CheckList Object to search for related opportunity

UW_Checklist__c aUW_Checklist = [Select Id, UW_Activity_Status__c from UW_checklist__c where Opportunity__c= :opportunityId LIMIT 1];

 if(aUW_Checklist!=null) {

//update status field

aUW_Checklist.UW_Activity_Status__c = 'Ready to Rate'; update aUW_Checklist;

oppExistInCw = true;

return oppExistInCw;

}

else {

return oppExistInCw;

}

 

 

}

}

 

I was trying to find some simple example syntax that I could use in the Execute Anonymous area of the IDE to test htis out. Can anyone provide an example I could reference?

 

Thanks

Please help in resolving errors like :

INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: