• Chrisparx
  • NEWBIE
  • 30 Points
  • Member since 2010

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

Hello,

 

I'm simply looking for how to retrieve the current API calls of the org through Apex but don't find anything similar in the documentation. I know that we can find this information in the company profile but I would like to get this information in my trigger/class in order to prevent future call according to my own limit (some calls are very important while other could wait 24 hours). Does anyone know how to get this information ?

 

Thank you !

Hello,

 

I'm looking to call an external URL from a trigger in order to send some informations based on the trigger itself...

 

I know I have to append the annotation @future, it's not the problem. If I call this URL from a button, it's completely working, but from a trigger, I have to convert my actual API.Session_ID and API.Partner_Server_URL_XXX to something else... and I don't find how I could do that. I just found that for the session_ID, I could use the UserInfo.getSessionId() ... but what about the Server URL ?? Could you provide some assistance ??

 

Thank you !!

Hello,

 

My problem is really simple: Trigger.new[X].HasSchedule (or old) seems not to be working. 

 

I explain more in details. I have a schedule under an Opportunity Product. By clicking on a button, I generate this schedule and also I copy some data to another tab. This step runs without any problem. But when I wish to delete the schedule (I click on "delete") and as the interaction with the schedule is limited, I had the idea to write a trigger (in order to delete the previously datas copied to the other tab) because I could simply detect if my opportunity product has still the schedule with Trigger.new[X].HasSchedule. It looks simple... The problem is that the result of Trigger.new[X].HasSchedule is always 'false'. I tested "HasSchedule" under a sql request under eclipse and it's working exactly as intended (result "true" if there is a schedule and false if not...).

 

Well I tried during a few hours lots of things as "Trigger.old", I separated the test with a "Trigger.isAfter" then a "Trigger.isBefore", but no way, the result is always 'false'. I tried lots of other similar things, nothing work..

 

Has someone already been confronted with this problem or has an idea where the problem could come ?

 

I hope this is the correct place to post this, as I can't seem to get any response from support on this.  I've joined the new system log console pilot, but I can't get any data in it at all.  I'm using Firefox and what happens is that the log gets an Unread entry, when I click on the entry, either nothing at all happens (none of the panes are populated) or I then get an error:

 

it says "Salesforce System Error" and shows the code
221574575-9535
(-1278617611)

Not the best start to a pilot...

 

Has anyone got this working?

Hello,

 

I'm simply looking for how to retrieve the current API calls of the org through Apex but don't find anything similar in the documentation. I know that we can find this information in the company profile but I would like to get this information in my trigger/class in order to prevent future call according to my own limit (some calls are very important while other could wait 24 hours). Does anyone know how to get this information ?

 

Thank you !

Hello,

 

I'm looking to call an external URL from a trigger in order to send some informations based on the trigger itself...

 

I know I have to append the annotation @future, it's not the problem. If I call this URL from a button, it's completely working, but from a trigger, I have to convert my actual API.Session_ID and API.Partner_Server_URL_XXX to something else... and I don't find how I could do that. I just found that for the session_ID, I could use the UserInfo.getSessionId() ... but what about the Server URL ?? Could you provide some assistance ??

 

Thank you !!

Is there any way to change or delete a Scheduled Job ?  I am able to create one easily enough, but once it is made I can only look at the values in the CronTrigger object, but not update them.  Also, it seems I cannot delete them.  I also looked at the System.AbortJob method, but that seems to only stop a job that is already running - I get an error if I try it on a Queued job.

 

The reason I am doing this is to try to create a 'sliding' job.  So, when a trigger is fired the job will run in 5 minutes.  But if the trigger is fired again before that 5 minutes is up, it will find the old job and either delete it and make a new one for 5 minutes out, or update the old one so the next scheduled time is in 5 minutes.

 

Any ideas are welcome!

 

Jason

 

 

Hello,

 

My problem is really simple: Trigger.new[X].HasSchedule (or old) seems not to be working. 

 

I explain more in details. I have a schedule under an Opportunity Product. By clicking on a button, I generate this schedule and also I copy some data to another tab. This step runs without any problem. But when I wish to delete the schedule (I click on "delete") and as the interaction with the schedule is limited, I had the idea to write a trigger (in order to delete the previously datas copied to the other tab) because I could simply detect if my opportunity product has still the schedule with Trigger.new[X].HasSchedule. It looks simple... The problem is that the result of Trigger.new[X].HasSchedule is always 'false'. I tested "HasSchedule" under a sql request under eclipse and it's working exactly as intended (result "true" if there is a schedule and false if not...).

 

Well I tried during a few hours lots of things as "Trigger.old", I separated the test with a "Trigger.isAfter" then a "Trigger.isBefore", but no way, the result is always 'false'. I tried lots of other similar things, nothing work..

 

Has someone already been confronted with this problem or has an idea where the problem could come ?

 

I have a custom button on a list view of contacts that allows users to check off as many as they want and then click the button. The button will check off a custom field on each contact's record.

 

Limited success. This works, but only when I choose 1 or 2 contacts. Any more than that and I get a "sforce is not defined" error.

 

Any insight as to why this is happening?

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} var connection = sforce.connection; var contactid = {!GETRECORDIDS( $ObjectType.Contact)}; // Make sure at least one Contact is selected if (!contactid.length) { alert("Please select at least one contact to enroll."); } else { var contact_to_update = new Array(); for (var i = 0; i < contactid.length; i++) { var callList = new sforce.SObject("Contact"); // Since we'll be using the update call, we must set the id // on the new job application record. callList.Id = contactid[i]; callList.Spring_Flying_Campaign__c="TRUE"; contact_to_update.push(callList); // Now make the update API call in a try statement so we can // catch any errors. Save the resulting array so we can also // check for problems with individual records. // var callCompleted = false; try { var result = sforce.connection.update(contact_to_update); callCompleted = true; } catch(error) { alert("Failed to update Field with error: " + error); } // Now check for problems with individual records. // if (callCompleted) { for (var i = 0; i < result.length; i++) { if (!result[i].getBoolean("success")) { alert("Contact (id='" + contactid[i] + "') could not be updated with error: " + result[i].errors); } } // Finally, refresh the browser to provide confirmation // to the user that the job applications were rejected. // window.location.reload(true); } } }

 

Note: Modified code from several other users but have forgotten who. So, thanks to those who shared their code!

 

All,

I've noticed that when setting Dataloader's batch size option to 200, triggers are operating in batches of 100. This is not a problem in itself, but I've also noticed that static variables are not cleared between the 100 batch runs. I've included a short example below, but basically all I'd like to know is:

Why are the Dataloader batches broken up, and when does this happen?
Should the static variables be cleared automatically?

As I say, here's a quick example; it's a trigger on Contact and a class with a static variable:

Code:
public class quickClass {
    public static boolean lock = false;
}
 

trigger quick on Contact (before insert) { 
    System.debug('lock: ' + quickClass.lock);
    quickClass.lock = true;
    System.debug('Trigger.new.size(): ' + Trigger.new.size());
 
}

When we insert, say, 150 Contacts, using Dataloader with a batch size of 200 in the log file we will see:

Code:
lock: false
Trigger.new.size(): 100
lock: true
Trigger.new.size(): 50

It doesn't look like it's Dataloader fault - it does look like it's sending 150 Contacts, rather than 100 and then 50.

Like I say, I don't mind the process being broken up, but obviously I'd also like the static variables to be cleared between the processing of the first 100 records finishing, and the processing of the next 50 records starting, as we are using static variables to control execution flow. If these variables are keeping their value, it causes a problem for us!

Hope that's enough detail, thanks in advance for any help...
Gary


  • December 05, 2008
  • Like
  • 1