• RK
  • NEWBIE
  • 0 Points
  • Member since 2005

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 20
    Replies
I've made some headway in creating a testmethod for my trigger that will populate a contacts Mobile phone and Phone2 on a newly created task.
However, I can't seem to figure out what to do to get my Test Coverage over 75% (It's currently 71%).

Does anything jump out that might indicate where issue (or most likely, issues) lie?

Trigger Code:
Code:
trigger Copy_Contact_Cell_and_Mobile_To_Task_Record on Task (after insert) 
{
Id ContactIDOnTheTask;
String contactCellNumber;
String contactPhone2;
    for (Task TReadOnly : Trigger.new)
if (TReadOnly.RecordTypeID == '012500000009Kbp')//Limit Code to only FID Tasks
 {//IfOpening
     {
        Task t = [select Id, WhoID from Task where Id = :TReadOnly.Id  limit 1]; //get ContactID
ContactIDOnTheTask= t.WhoID;
Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,c.Phone_2__c from Contact c 
where c.Id = :ContactIDOnTheTask limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   {//4
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array
contactPhone2 = phoneValueArray[0].Phone_2__c;  //grab phone2 number from array
t.Mobile__c = contactCellNumber;  //set mobile custom field on task to the contact mobile number
t.Phone2__c = contactPhone2;  //set phone2 custom field on task to contact phone2 number
   }//4
  update t;
  }
 }//IfClosing
}

TestMethod:
Code:
public class taskTriggerTestMethod {//1

static testMethod void myTest() {//2
//Declare Variables
Id ContactIDOnTheTask;
String contactCellNumber ;
String contactCellNumber2 ;
String acontactPhoneNumber2;
String bcontactPhoneNumber2;
date taskydate = System.today();
 // Create two Tasks for test
   Task t1 = new task(ActivityDate = taskydate, OwnerId ='00530000000hxwA',   Results__c = 'Contact', Subject='Task1Test', WhoID = '0035000000RzAaw', RecordTypeID = '012500000009Kbp');
insert t1;
 
 Task t2 = new task(ActivityDate = taskydate, OwnerId ='00530000000hxwA', Results__c = 'Contact', Subject='Task2Test', WhoID = '0035000000RzAaw', RecordTypeID = '012500000009Kbp');
 insert t2;  


 //Grab Details From Task 1
 Task t = [select Id, WhoID, Mobile__c,Phone2__c from Task where Id = :t1.Id  limit 1]; //get ContactID


Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,Phone2__c from Contact c 
where c.Id = :t.WhoID limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   
acontactPhoneNumber2 = phoneValueArray[0].Phone2__c; //grab Phone 2 from array
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array

  
//Grab Details From Task 2
Task t4 = [select Id, WhoID, Mobile__c,Phone2__c from Task where Id = :t2.Id  limit 1]; //get ContactID

Contact[] phoneValueArray2 = [Select c.Id,c.mobilePhone,Phone2__c from Contact c 
where c.Id = :t4.WhoID limit 1]; 
for(Integer i=0;i<phoneValueArray2.size();i++)
   
bcontactPhoneNumber2 = phoneValueArray2[0].Phone2__c;
contactCellNumber2 = phoneValueArray2[0].mobilePhone;  //grab mobile number from array
  
//Tests
  System.assert(t1.ID != NULL);
  System.assert(t2.ID != NULL);
  System.assertEquals(t1.Mobile__c,contactCellNumber);
  System.assertEquals(t2.Mobile__c,contactCellNumber2);
  System.assertEquals(t1.Phone2__c,acontactPhoneNumber2);
  System.assertEquals(t2.Phone2__c,bcontactPhoneNumber2);
 
 } 
}//1

 Debug Log:
Code:
*** Beginning Test 1: taskTriggerTestMethod.static testMethod void myTest()

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 13, column 1: Insert: SOBJECT:Task
*** Beginning Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiT

20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 6, column 5: SelectLoop:LIST:SOBJECT:Task
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 10, column 18: SOQL query with 1 row finished in 6 ms
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 12, column 29: SOQL query with 1 row finished in 4 ms
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: Update: SOBJECT:Task
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: DML Operation executed in 28 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 500
Number of DML statements: 2 out of 100
Number of DML rows: 2 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 20 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Copy_Contact_Cell_and_Mobile_To_Task_Record:ContactIDOnTheTask:18
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactCellNumber:0
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactPhone2:10


*** Ending Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiT

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 13, column 1: DML Operation executed in 92 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 16, column 2: Insert: SOBJECT:Task
*** Beginning Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiU

20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 6, column 5: SelectLoop:LIST:SOBJECT:Task
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 10, column 18: SOQL query with 1 row finished in 3 ms
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 12, column 29: SOQL query with 1 row finished in 5 ms
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: Update: SOBJECT:Task
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: DML Operation executed in 27 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 500
Number of DML statements: 4 out of 100
Number of DML rows: 4 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 34 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Copy_Contact_Cell_and_Mobile_To_Task_Record:ContactIDOnTheTask:18
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactCellNumber:0
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactPhone2:10


*** Ending Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiU

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 16, column 2: DML Operation executed in 63 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 20, column 11: SOQL query with 1 row finished in 3 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 23, column 29: SOQL query with 1 row finished in 6 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 32, column 11: SOQL query with 1 row finished in 3 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 34, column 30: SOQL query with 1 row finished in 6 ms
System.Exception: Assertion Failed: Expected: null, Actual: 1234567890

Class.taskTriggerTestMethod.myTest: line 46, column 3


Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 8 out of 100
Number of query rows: 8 out of 500
Number of DML statements: 4 out of 100
Number of DML rows: 4 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 49 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Stack frame variables and sizes:
Frame0

*** Ending Test taskTriggerTestMethod.static testMethod void myTest()

 


 


  • January 08, 2008
  • Like
  • 0
Hey all,
With Apex now being available in EE, some new opportunities have opened to address requests from my users.

One of them is fairly straightforward - my users would like to see a contacts cellular number automatically populated on the task record - this would prevent them from needing to toggle back to the Contact record.

I played around in my DE account and got it working A-OK.  All good.

However, when I go to deploy the code via Eclipse to my prod environment, I get the message about coverage:
"Copy_Contact_Cell_and_Mobile_To_Task_Record Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
  Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required"

I've read some of the other posts referring to the Code preview doc and the PDF overview of the, but my ignorant, non-programmer mind is struggling to make any headway in correcting the error.

I've enclosed my code below.  Am I missing something easy?  Or is this much more complicated in Production than it is in Dev.

Any guidance would be appreciated..
Thanks,
RK
Code:
trigger Copy_Contact_Cell_and_Mobile_To_Task_Record on Task (after insert) 
{
Id ContactIDOnTheTask;
String contactCellNumber;
String contactPhone2;
    for (Task TReadOnly : Trigger.new)
if (TReadOnly.RecordTypeID == '0123000000005z2')//Limit Code to only FID Tasks
 {//IfOpening
     {
        Task t = [select Id, WhoID from Task where Id = :TReadOnly.Id  limit 1]; //get ContactID
ContactIDOnTheTask= t.WhoID;
Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,c.Phone_2__c from Contact c 
where c.Id = :ContactIDOnTheTask limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   {//4
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array
contactPhone2 = phoneValueArray[0].Phone_2__c;  //grab phone2 number from array
t.Mobile__c = contactCellNumber;  //set mobile custom field on task to the contact mobile number
t.Phone2__c = contactPhone2;  //set phone2 custom field on task to contact phone2 number
   }//4
  update t;
  }
 }//IfClosing
}

 

  • January 06, 2008
  • Like
  • 0
Hey All,
Well, I finally realized that I was going to in some way learn to do some remedial code in Apex if I'm going to extend the app to where I want it to go.

I've created a very basic trigger that, when a contact is updated, will go out to the Contact Owner user record and grab data from a custom field on the Contact Owner record.

I have figured out how to query the OwnerID just fine.  However, I do not seem to be able to dynamically query for the custom field data on the Contact Owner User Record by using hte OwnerID.  When I attempt to complie, I get a message stating: Error: Compile Error: unexpected token: contactOwnerID at line 10 column 82.  I've highlighted the line in my code that is causing the error.

Also - if I hard code in a UserID (mine, for example), the trigger works just fine.  A working example of a modified version of the red code in my Trigger code would be:
User[] AThreshValue = [Select u.A_Producer_Threshold__c from User u where u.Id = '00530000000hxwA' limit 1];

Any thoughts?  I'm sure I'm missing something (which is probably obvious), but I just can get my non-programming-mind around what else I need to do.  And I have spent a good deal of time searching the forums & wikis for information.

Thanks, as always,
RK

Code:
trigger UpdateAThreshold on Contact (before update) {//1
Id contactOwnerID;
for (Contact c :trigger.new)

{//2
Contact[] OwnerIdArray = [Select OwnerId from Contact where Id in :Trigger.new limit 1];
for(Integer i=0;i<OwnerIdArray.size();i++){//3
contactOwnerID = OwnerIdArray[0].OwnerId;
c.l_Total_Widget_B_Production__c = contactOwnerID ; //This is a test line - I did this just to test if I could get a field to update
User[] AThreshValue = [Select u.A_Producer_Threshold__c from User u where u.Id = contactOwnerID limit 1]; //This is my problem area.
//I want to be able to query the A Producer Threshold data from the Contact Owner, but the code will not compile

for(Integer j=0;i<AThreshValue.size();i++){//4
double contactOwnerID2;
contactOwnerID2 = AThreshValue [0].A_Producer_Threshold__c; //This is where I want to query the custom field on the record of the Contact Owner.
c.A_Producer_Threshold__c = contactOwnerID2; // And here is where I want to push the custom field data to the contact object
}//4
}//3
}//2
}//1

 

Message Edited by RK on 09-23-2007 10:31 PM

Message Edited by RK on 09-23-2007 10:31 PM

  • September 24, 2007
  • Like
  • 0
Hey all,
I think I know the answer, but wanted to ask it anyways...

I have built a custom object that contains data pertaining to PDF forms that we have, such as state(s) that the form is approved in, product(s) that the form pertains to, description of the form, etc.  The PDF form is actually attached to the Custom Object.

What I would like to do is be able to provide a custom link from the Custom Object that will launch a new Email window within Salesforce.com and have the PDF that is attached to the Custom Object attached to the Email.

I know this would be possible if the attachement/PDF existed within the Documents folder, but I lose my ability to do extra customization/categorization that I can do via a custom object.  Likewise, I could create a link to the PDF in the document area directly on the Custom Object, but I beleive it would be a bit too complicated for them to do that with any regularity.  Lastly - I know that there are fee-based AppExchange packages that could probably do this, but the need at the moment does not warrant extra fees.

Ryan
  • September 14, 2007
  • Like
  • 0
Hey all,
I recently saw a post come through via my RSS feed that provided some sample code around how to get a pop-up box to appear in an SControl that would provide a user a list of data elements in a drop down, one of which they could "select" and click "Submit".  Unfortunately, I cleared out my feed reader and cannot find the post anymore

I would like to use something like this to create a pop-up window that i could put on a contact record that would plug a selectable value into an existing report.

For example, I could have a link to a report on teh contact record, and upon clicking the link the user would be prompted with a box that contains all the unique values of a multi-select field on the opportunity object (Product on the opportunity, for example).  The value that the user selects could then via the SControl be pumped into an existing report, thereby negating the need for the user to navigate to the reports tab and change the parameter on the existing report.

Does this ring a bell with anyone? 

Here's to a great Dreamforce..

RK
  • September 14, 2007
  • Like
  • 0
Hey all,
I'm scratching my head a bit on a request from my users, and I thought I'd ping you guys to see if you have any insight.

I've developed a SControl that will query the group of contacts that a particular user is responsible for and will auto-create a task (phone call) for the user.  It is invisioned that this SControl would be invoked every 28 days.

The calls should be spread out over 28 days.  So, if I have 280 people that I'm responsible for today, I would have 10 people to call today, 10 tomorrow, 10 the day after, etc (I'm ignoring weekends at the moment).

My trouble lies here:
- I want the day that a contact is called to stay consistent within the 28 day window.  So, if the SControl assigns a call for Joe Smith on the 6th day of the cycle when I run it this month, I want it to assign him to the 6th day of the cycle when I run it next month.  This will help provide a relatively constant & consistent contact model.

For the life of me, I cant' think of a trigger for this.  I was thinking about using the day of the birthday, but there is a lot of variability in the number of birthdays.

Any thoughts?  Am I missing something easy?
  • June 22, 2007
  • Like
  • 0
Hey all,
I've seen examples where some query results could be displayed in an Inline-SControl on a page.

For example, I could have a custom object called "Business Plan".   Within the Custom Object, there could be a section that calls an SControl that goes out, grabs the first name, last name, phone number and total sales for all producers that have a custom field of "Tier" flagged as an "A".  The contents of this section would change as the people who are tagged as A's change. 

I thought that there was something in the DreamForce 06 presentations (SControls for Dummies, for example), but I couldn't find anything.  Also, I seem to recall that there was an SF.com app out on the AppExchange that essentially did this, but I couldn't find it, either (The Mass Update Opportuntiies in some ways does it, but it is much more complex that my needs)..I thought that it was a mass view of contacts, but I might be wrong.  And I recall the foundation being the use of the SF.com Style Sheets.

Wondering if anyone has the same recollection as me.  As I have done many times in the past (with all of your help), I plan on re-engineering the existing code to fit the specific needs of my users.

Thanks much for any insight...
RK

P.S.  If you are like me and you don't have the knowledge to do coding on your own and you rely on reverse engineering other people's code, please vote on my Idea below.  Thanks!
http://ideas.salesforce.com/article/show/57416/A_UserSubmitted_CodeSControlEnhancement_Sample_Library

Message Edited by RK on 04-19-2007 08:26 AM

  • April 19, 2007
  • Like
  • 0
Hey all,
As I continue to build my S-Controls,I'm stumbling upon some that are taking a bit longer to execute.  So my users know that the system is working and that the IE window is just not frozen, I want to present a pop-up status window stating something along the lines of "Please Wait...Records Being Processed" while a status bar moves below the messagte

I seem to recall one of the SControl examples posted either here, at Dreamforce or on the AppExchange possessing something like this for a Mass-Update use.

Anyone recall which it was?  I thought it was the "Mass Update Opportunities", but that doesn't seem to be the case.

Thanks, as always, for any input.

RK
  • April 03, 2007
  • Like
  • 0
Hey all,
I've recently created an SControl that will create follow-up tasks for my users based upon the last time a key contact has been created.  The basic premise is that anyone that is within the first tier of producers (i.e. their A producers) should be spoken to every 30 days.

So, based upon the "Last Activity" field and the tier field, I can rather easily figure out who should be targetted.

In the case of the A producers, they should be contacted "Today - 30 days".

I created an S Control to create the tasks, but I struggled on the formatting of the date to be passed to the Last Activity field - I know that it needs to be in the format of YYYY-MM-DD, but I was never able to get the date format in the format that would work.

As a work around, I have the SControl prompt me for the date, for which I'll type "2007-02-23".  But, I'd much rather have it just be automatic (check out the red highlighted section in the code below).

I'll run this manually on a somewhat regular basis.

Any thoughts?
As always, thanks for the input.
RK

<html>

<head>

<script src="/soap/ajax/9.0/connection.js"></script>

<script>

var d = new Date(); //will give today's date
document.write(d+"<br>"); //displays today's date
d.setDate(d.getDate()-30); //subtract 30 days from today's date.  Ideally, this is passed against the "Last Activity Date"
document.write(d); //display what that date is
//alert("//alertingdate");
//alert(d);
var taskType = '012300000000PvkAAE';
var followUpTaskType = 'Outbound Call';
var followUpTaskSubject = 'Top 50 advisor not contacted in 30 days';
var followUpResults = 'Follow-Up';
var whatTaskDate = prompt('What is the date?',' ');
var followUpDate = {!Today};
var followUpTaskNotes = 'Call to make contact with one of your top 50 advisors - no contact has been made in the last 30 days';
var followUpTaskStatus = 'Not Started';
var followUpSubType = 'Tier 1 - Regular Contact';




function createTask() {
var queryContact = sforce.connection.query("Select Id, OwnerId from Contact where X2006_Rank_Within_Region__c > 0 and X2006_Rank_Within_Region__c < 51 and RecordTypeId = '0123000000005yGAAQ' and Known_Terminated__c = FALSE and ((lastactivitydate = null) or (lastactivitydate < "+whatTaskDate+"))limit 150");

//alert(queryContact);


contactsToBeTasked = queryContact.getArray("records");
//alert ("contactsToBeTasked");
//alert (contactsToBeTasked);
//var contactsToBeTaskedArray = new Array();


var contactsToBeTaskedArray= new Array();
//alert("Array Created");
//alert(contactsToBeTaskedArray);

var records = queryContact.getArray('records');

for (var i = 0; i < records.length; i++)
{
taskCreatedLineItem = contactsToBeTasked[i];
//alert(taskCreatedLineItem.get("Id"));
var neglectedContactTask = new sforce.SObject("Task");
//alert("DynaBean");
neglectedContactTask.set("RecordTypeId",taskType);
//alert("typeset");
neglectedContactTask.set("Type",followUpTaskType);
//alert ("Task Type Set");
neglectedContactTask.set("Subject",followUpTaskSubject);
//alert("SubSet");
neglectedContactTask.set("Status",followUpTaskStatus);
//alert("StatSet");
neglectedContactTask.set("Description",followUpTaskNotes);
//alert("CommSet");
neglectedContactTask.set("ActivityDate",new Date('{!Today}') );
//alert("dateset");
neglectedContactTask.set("OwnerId",taskCreatedLineItem .get("OwnerId"));
//alert("OwnerSet");
neglectedContactTask.set("WhoId",taskCreatedLineItem .get("Id"));
//alert("ConIDSet");
neglectedContactTask.set("Call_Sub_Type__c",followUpSubType );
//alert("SubType");
contactsToBeTaskedArray.push(neglectedContactTask);
//alert("Pushed");
}
var saveArrayResults = sforce.connection.create(contactsToBeTaskedArray);

}

</script>

</head>

<body onload="createTask();">

</body>

</html>
  • March 24, 2007
  • Like
  • 0
Hey all,
A new process is being developed within my sales organization where a group of people, on a daily basis, will manually create "Thank you" calls for another group of users.

Who the calls should be assigned to is based off of a custom field on the User Record of the Contact Owner (a relationship field).

So, since the calls are all essentially the same, I'm trying to allow the task-enteres to click a single link to create the task.

I can't seem to anything to query from the user table.  Here are my variable declaratoins.  As you will see near the bottom (for testing purposes)


var contactOwnerId = '{!Contact.OwnerId}';  //Here I'm grabbing the OwnerID from the Contact Record
alert (contactOwnerId );
alert("owenrID");
var firstTicketContactId = '{!Contact.Id}';
var firstTicketTaskSubject = 'First Ticket Follow-up Call';
var firstTicketResults = 'Follow-Up';
var firstTicketDate = {!Today};
var firstTicketTaskNotes = prompt('What are the comments for the task?',' ');
var firstTicketTaskStatus = 'Not Started';
//below is the query that where I'm trying to get the first name of the Contact Owner from the user table
var internalWholesalerId = sforceClient.Query("Select FirstName from User where Id = "'+contactOwnerId+"'");'
alert (internalWholesalerId);

So, even a simple query of pulling the first name from the user table returns a value of Undefined.

Thoughts?  As always, thanks for educating the ignorant (i.e. Me).

  • March 15, 2007
  • Like
  • 0
Hey all,
Well, I've finally figured out how to do some rudimenary S-Controls.  Thanks to those of you who have provided me guidance along the way.

I don't think what I want to now do is possible, but I figured I would ask:

When my users enter a task, there is a required field called Type.

When my users select a particular type on the task, I would like a field to update on the related contact record.

Is this in any way possible?

Thanks, as always...
  • February 27, 2007
  • Like
  • 0
Hey all,
I currently have a custom object that represents a piece of marketing material (i.e. a flyer, brouchere, etc).  These marketing materials need to be approved by the banks in which they are to be distributed, and to help disseminate the approval information, I created a relationship object that is displayed via a related list on the marketing Material object.

The user that maintains the marketing materials has 15 banks (which are accounts) that will automatically approve any material that we develop.  Rather than make her create 15 different relationship objects (called "Marketing Material Approvals") I developed an SControl to auto create the 15 relationship objects.

Essentially, I just took an SControl that would create a single relationship and copied it the code for the SControl multiple times - one for each bank.

THe SControl works, but it stops after creating the relationship for 2 or 3 banks.  I have found that if I move those banks that have the shortest names to the top of the code that it will create more of the relationship objects before it stops, leading me to beleive that I have hit a limit of some sort.

Any thoughts?   This would be quite the time saver for my user..

Thanks, as always.
LT


<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "Webster Bank"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    Linsco/Private Ledger (LPL)&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK="My First Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "My Second Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "My Third Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>

Message Edited by RK on 01-14-2007 06:23 AM

  • January 14, 2007
  • Like
  • 0
Hey all,
As I've mentioned previously in these boards, I have next to no programming knowledge.  I'm not given the time or opportunity to do much actual study, so I try to learn by reverse engineering.

At DF this year, I attended the SForce For Dummies (very fitting for me :) ).  During that class, I was able to get my hands on a piece of AJAX code that will update all the addresses on contacts under an account.

Although this specfic data (address) is not applicable in my org, there are many data elements on an account that I would love to have update down to the contact level.

Attached below is the code that was provided in the PPT from the demo.  I've tried tweaking, adding (I know that I need to call out the toolkit at the start of the code), subtracting, changing but can not get it to work.

Anyone have any quick suggestions?  I know I'm missing something, but I'm not sure if I'm missing something big or something small.

Any guidance would be much appreciated by an ignorant programmer.
Thanks much,
RK


var queryResult =sforceClient.Query("Select BillingCity, BillingCountry, BillingPostalCode, BillingState, BillingStreet from Account Where Id = '" + accId + "'");
    
    var BillingCity = "";
    var BillingCountry = "";
    var BillingPostalCode = "";
    var BillingState = "";
    var BillingStreet = "";
    //move results into readable format   
    var address = queryResult.records[0];
   // assign address attribs to variables
    BillingCity = address.billingcity;
    BillingCountry = address.billingcountry;
    BillingPostalCode = address.billingpostalcode;
    BillingState = address.billingstate;
    BillingStreet = address.billingstreet;

//query to get contacts associated with account
    var queryResult2 =sforceClient.Query("Select Id,LastName,MailingCity, MailingCountry, MailingPostalCode, MailingState, MailingStreet from Contact Where AccountId = '" + accId + "'");
//new array to hold results of updates
    var updateObjects = new Array();

// go through list of contacts to update addresses
    for (var i=0;i<queryResult2.records.length;i++){
        var contact = queryResult2.records[i];

        contact.set("MailingCity",BillingCity);
        contact.set("MailingCountry",BillingCountry);       
        contact.set("MailingPostalCode",BillingPostalCode);
        contact.set("MailingState",BillingState);   
        contact.set("MailingStreet",BillingStreet);
// have to push updated record into new array for update process
        updateObjects.push(contact);
        }
// submit new array with updated contacts
    var saveResults = sforceClient.Update(updateObjects);
  • October 29, 2006
  • Like
  • 0
Hey all,
As my subject line might indicate, I am very, very inexperienced when it comes to doing any programming.  I am very comfortable with sf as a whole, but I would like to start extending myself and branching out into the world of writing s-controls and using the API's.

As an example of a project that I would like to do - setup an auto-update that would run via a batch/trigger from a local machine on a nightly basis that would truncate a contact field on a select group of contacts. 

I would also like to start learning how I can setup automated feeds - both into and out of sf.

More or less, I don't know what I don't know.  I just don't know what is possible.  And I'd like to start reading up.

Any suggestions as to where someone that is as green as I should start?

Thanks in advance,
RK
  • September 30, 2006
  • Like
  • 0
I've made some headway in creating a testmethod for my trigger that will populate a contacts Mobile phone and Phone2 on a newly created task.
However, I can't seem to figure out what to do to get my Test Coverage over 75% (It's currently 71%).

Does anything jump out that might indicate where issue (or most likely, issues) lie?

Trigger Code:
Code:
trigger Copy_Contact_Cell_and_Mobile_To_Task_Record on Task (after insert) 
{
Id ContactIDOnTheTask;
String contactCellNumber;
String contactPhone2;
    for (Task TReadOnly : Trigger.new)
if (TReadOnly.RecordTypeID == '012500000009Kbp')//Limit Code to only FID Tasks
 {//IfOpening
     {
        Task t = [select Id, WhoID from Task where Id = :TReadOnly.Id  limit 1]; //get ContactID
ContactIDOnTheTask= t.WhoID;
Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,c.Phone_2__c from Contact c 
where c.Id = :ContactIDOnTheTask limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   {//4
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array
contactPhone2 = phoneValueArray[0].Phone_2__c;  //grab phone2 number from array
t.Mobile__c = contactCellNumber;  //set mobile custom field on task to the contact mobile number
t.Phone2__c = contactPhone2;  //set phone2 custom field on task to contact phone2 number
   }//4
  update t;
  }
 }//IfClosing
}

TestMethod:
Code:
public class taskTriggerTestMethod {//1

static testMethod void myTest() {//2
//Declare Variables
Id ContactIDOnTheTask;
String contactCellNumber ;
String contactCellNumber2 ;
String acontactPhoneNumber2;
String bcontactPhoneNumber2;
date taskydate = System.today();
 // Create two Tasks for test
   Task t1 = new task(ActivityDate = taskydate, OwnerId ='00530000000hxwA',   Results__c = 'Contact', Subject='Task1Test', WhoID = '0035000000RzAaw', RecordTypeID = '012500000009Kbp');
insert t1;
 
 Task t2 = new task(ActivityDate = taskydate, OwnerId ='00530000000hxwA', Results__c = 'Contact', Subject='Task2Test', WhoID = '0035000000RzAaw', RecordTypeID = '012500000009Kbp');
 insert t2;  


 //Grab Details From Task 1
 Task t = [select Id, WhoID, Mobile__c,Phone2__c from Task where Id = :t1.Id  limit 1]; //get ContactID


Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,Phone2__c from Contact c 
where c.Id = :t.WhoID limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   
acontactPhoneNumber2 = phoneValueArray[0].Phone2__c; //grab Phone 2 from array
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array

  
//Grab Details From Task 2
Task t4 = [select Id, WhoID, Mobile__c,Phone2__c from Task where Id = :t2.Id  limit 1]; //get ContactID

Contact[] phoneValueArray2 = [Select c.Id,c.mobilePhone,Phone2__c from Contact c 
where c.Id = :t4.WhoID limit 1]; 
for(Integer i=0;i<phoneValueArray2.size();i++)
   
bcontactPhoneNumber2 = phoneValueArray2[0].Phone2__c;
contactCellNumber2 = phoneValueArray2[0].mobilePhone;  //grab mobile number from array
  
//Tests
  System.assert(t1.ID != NULL);
  System.assert(t2.ID != NULL);
  System.assertEquals(t1.Mobile__c,contactCellNumber);
  System.assertEquals(t2.Mobile__c,contactCellNumber2);
  System.assertEquals(t1.Phone2__c,acontactPhoneNumber2);
  System.assertEquals(t2.Phone2__c,bcontactPhoneNumber2);
 
 } 
}//1

 Debug Log:
Code:
*** Beginning Test 1: taskTriggerTestMethod.static testMethod void myTest()

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 13, column 1: Insert: SOBJECT:Task
*** Beginning Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiT

20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 6, column 5: SelectLoop:LIST:SOBJECT:Task
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 10, column 18: SOQL query with 1 row finished in 6 ms
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 12, column 29: SOQL query with 1 row finished in 4 ms
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: Update: SOBJECT:Task
20080108223753.087:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: DML Operation executed in 28 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 500
Number of DML statements: 2 out of 100
Number of DML rows: 2 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 20 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Copy_Contact_Cell_and_Mobile_To_Task_Record:ContactIDOnTheTask:18
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactCellNumber:0
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactPhone2:10


*** Ending Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiT

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 13, column 1: DML Operation executed in 92 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 16, column 2: Insert: SOBJECT:Task
*** Beginning Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiU

20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 6, column 5: SelectLoop:LIST:SOBJECT:Task
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 10, column 18: SOQL query with 1 row finished in 3 ms
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 12, column 29: SOQL query with 1 row finished in 5 ms
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: Update: SOBJECT:Task
20080108223753.155:Trigger.Copy_Contact_Cell_and_Mobile_To_Task_Record: line 21, column 3: DML Operation executed in 27 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 500
Number of DML statements: 4 out of 100
Number of DML rows: 4 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 34 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Copy_Contact_Cell_and_Mobile_To_Task_Record:ContactIDOnTheTask:18
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactCellNumber:0
Copy_Contact_Cell_and_Mobile_To_Task_Record:contactPhone2:10


*** Ending Copy_Contact_Cell_and_Mobile_To_Task_Record on Task trigger event bulk AfterInsert for 00T5000000dkDiU

20080108223753.034:Class.taskTriggerTestMethod.myTest: line 16, column 2: DML Operation executed in 63 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 20, column 11: SOQL query with 1 row finished in 3 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 23, column 29: SOQL query with 1 row finished in 6 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 32, column 11: SOQL query with 1 row finished in 3 ms
20080108223753.034:Class.taskTriggerTestMethod.myTest: line 34, column 30: SOQL query with 1 row finished in 6 ms
System.Exception: Assertion Failed: Expected: null, Actual: 1234567890

Class.taskTriggerTestMethod.myTest: line 46, column 3


Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 8 out of 100
Number of query rows: 8 out of 500
Number of DML statements: 4 out of 100
Number of DML rows: 4 out of 500
Number of transaction control statements: 0 out of 0
Number of script statements: 49 out of 200000
Maximum heap size: 0 out of 500000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10

Total email recipients queued to be sent : 0
Stack frame variables and sizes:
Frame0

*** Ending Test taskTriggerTestMethod.static testMethod void myTest()

 


 


  • January 08, 2008
  • Like
  • 0
Hey all,
With Apex now being available in EE, some new opportunities have opened to address requests from my users.

One of them is fairly straightforward - my users would like to see a contacts cellular number automatically populated on the task record - this would prevent them from needing to toggle back to the Contact record.

I played around in my DE account and got it working A-OK.  All good.

However, when I go to deploy the code via Eclipse to my prod environment, I get the message about coverage:
"Copy_Contact_Cell_and_Mobile_To_Task_Record Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
  Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required"

I've read some of the other posts referring to the Code preview doc and the PDF overview of the, but my ignorant, non-programmer mind is struggling to make any headway in correcting the error.

I've enclosed my code below.  Am I missing something easy?  Or is this much more complicated in Production than it is in Dev.

Any guidance would be appreciated..
Thanks,
RK
Code:
trigger Copy_Contact_Cell_and_Mobile_To_Task_Record on Task (after insert) 
{
Id ContactIDOnTheTask;
String contactCellNumber;
String contactPhone2;
    for (Task TReadOnly : Trigger.new)
if (TReadOnly.RecordTypeID == '0123000000005z2')//Limit Code to only FID Tasks
 {//IfOpening
     {
        Task t = [select Id, WhoID from Task where Id = :TReadOnly.Id  limit 1]; //get ContactID
ContactIDOnTheTask= t.WhoID;
Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,c.Phone_2__c from Contact c 
where c.Id = :ContactIDOnTheTask limit 1]; 
for(Integer i=0;i<phoneValueArray.size();i++)
   {//4
contactCellNumber = phoneValueArray[0].mobilePhone;  //grab mobile number from array
contactPhone2 = phoneValueArray[0].Phone_2__c;  //grab phone2 number from array
t.Mobile__c = contactCellNumber;  //set mobile custom field on task to the contact mobile number
t.Phone2__c = contactPhone2;  //set phone2 custom field on task to contact phone2 number
   }//4
  update t;
  }
 }//IfClosing
}

 

  • January 06, 2008
  • Like
  • 0
Hey All,
Well, I finally realized that I was going to in some way learn to do some remedial code in Apex if I'm going to extend the app to where I want it to go.

I've created a very basic trigger that, when a contact is updated, will go out to the Contact Owner user record and grab data from a custom field on the Contact Owner record.

I have figured out how to query the OwnerID just fine.  However, I do not seem to be able to dynamically query for the custom field data on the Contact Owner User Record by using hte OwnerID.  When I attempt to complie, I get a message stating: Error: Compile Error: unexpected token: contactOwnerID at line 10 column 82.  I've highlighted the line in my code that is causing the error.

Also - if I hard code in a UserID (mine, for example), the trigger works just fine.  A working example of a modified version of the red code in my Trigger code would be:
User[] AThreshValue = [Select u.A_Producer_Threshold__c from User u where u.Id = '00530000000hxwA' limit 1];

Any thoughts?  I'm sure I'm missing something (which is probably obvious), but I just can get my non-programming-mind around what else I need to do.  And I have spent a good deal of time searching the forums & wikis for information.

Thanks, as always,
RK

Code:
trigger UpdateAThreshold on Contact (before update) {//1
Id contactOwnerID;
for (Contact c :trigger.new)

{//2
Contact[] OwnerIdArray = [Select OwnerId from Contact where Id in :Trigger.new limit 1];
for(Integer i=0;i<OwnerIdArray.size();i++){//3
contactOwnerID = OwnerIdArray[0].OwnerId;
c.l_Total_Widget_B_Production__c = contactOwnerID ; //This is a test line - I did this just to test if I could get a field to update
User[] AThreshValue = [Select u.A_Producer_Threshold__c from User u where u.Id = contactOwnerID limit 1]; //This is my problem area.
//I want to be able to query the A Producer Threshold data from the Contact Owner, but the code will not compile

for(Integer j=0;i<AThreshValue.size();i++){//4
double contactOwnerID2;
contactOwnerID2 = AThreshValue [0].A_Producer_Threshold__c; //This is where I want to query the custom field on the record of the Contact Owner.
c.A_Producer_Threshold__c = contactOwnerID2; // And here is where I want to push the custom field data to the contact object
}//4
}//3
}//2
}//1

 

Message Edited by RK on 09-23-2007 10:31 PM

Message Edited by RK on 09-23-2007 10:31 PM

  • September 24, 2007
  • Like
  • 0
Hey all,
I recently saw a post come through via my RSS feed that provided some sample code around how to get a pop-up box to appear in an SControl that would provide a user a list of data elements in a drop down, one of which they could "select" and click "Submit".  Unfortunately, I cleared out my feed reader and cannot find the post anymore

I would like to use something like this to create a pop-up window that i could put on a contact record that would plug a selectable value into an existing report.

For example, I could have a link to a report on teh contact record, and upon clicking the link the user would be prompted with a box that contains all the unique values of a multi-select field on the opportunity object (Product on the opportunity, for example).  The value that the user selects could then via the SControl be pumped into an existing report, thereby negating the need for the user to navigate to the reports tab and change the parameter on the existing report.

Does this ring a bell with anyone? 

Here's to a great Dreamforce..

RK
  • September 14, 2007
  • Like
  • 0
I'm trying to auto-update a record when a user clicks the "edit" button.  I've written an update query, but the control is giving me a "malformed query" error message.  Are we able to write update queries through ajax?

Also, is there any kind of white paper for the SOQL language?
I am getting the following error when trying to install the Apex Toolkit for Eclipse.
 
Code:
Network connection problems encountered during search.
  Unable to access "http://adnsandbox.com/appexchange/e3.2s".
    Error parsing site stream. [Premature end of file.]
    Premature end of file.
    Error parsing site stream. [Premature end of file.]
    Premature end of file.
  Unable to access "http://download.eclipse.org/releases/europa".
    Error parsing site stream. [Premature end of file.]
    Premature end of file.
    Error parsing site stream. [Premature end of file.]
    Premature end of file.

 
I have a fresh install of Eclipse 3.3.0
Windows XP Professional SP2
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Hey all,
I'm scratching my head a bit on a request from my users, and I thought I'd ping you guys to see if you have any insight.

I've developed a SControl that will query the group of contacts that a particular user is responsible for and will auto-create a task (phone call) for the user.  It is invisioned that this SControl would be invoked every 28 days.

The calls should be spread out over 28 days.  So, if I have 280 people that I'm responsible for today, I would have 10 people to call today, 10 tomorrow, 10 the day after, etc (I'm ignoring weekends at the moment).

My trouble lies here:
- I want the day that a contact is called to stay consistent within the 28 day window.  So, if the SControl assigns a call for Joe Smith on the 6th day of the cycle when I run it this month, I want it to assign him to the 6th day of the cycle when I run it next month.  This will help provide a relatively constant & consistent contact model.

For the life of me, I cant' think of a trigger for this.  I was thinking about using the day of the birthday, but there is a lot of variability in the number of birthdays.

Any thoughts?  Am I missing something easy?
  • June 22, 2007
  • Like
  • 0
Hey all,
I've seen examples where some query results could be displayed in an Inline-SControl on a page.

For example, I could have a custom object called "Business Plan".   Within the Custom Object, there could be a section that calls an SControl that goes out, grabs the first name, last name, phone number and total sales for all producers that have a custom field of "Tier" flagged as an "A".  The contents of this section would change as the people who are tagged as A's change. 

I thought that there was something in the DreamForce 06 presentations (SControls for Dummies, for example), but I couldn't find anything.  Also, I seem to recall that there was an SF.com app out on the AppExchange that essentially did this, but I couldn't find it, either (The Mass Update Opportuntiies in some ways does it, but it is much more complex that my needs)..I thought that it was a mass view of contacts, but I might be wrong.  And I recall the foundation being the use of the SF.com Style Sheets.

Wondering if anyone has the same recollection as me.  As I have done many times in the past (with all of your help), I plan on re-engineering the existing code to fit the specific needs of my users.

Thanks much for any insight...
RK

P.S.  If you are like me and you don't have the knowledge to do coding on your own and you rely on reverse engineering other people's code, please vote on my Idea below.  Thanks!
http://ideas.salesforce.com/article/show/57416/A_UserSubmitted_CodeSControlEnhancement_Sample_Library

Message Edited by RK on 04-19-2007 08:26 AM

  • April 19, 2007
  • Like
  • 0
Hey all,
I've recently created an SControl that will create follow-up tasks for my users based upon the last time a key contact has been created.  The basic premise is that anyone that is within the first tier of producers (i.e. their A producers) should be spoken to every 30 days.

So, based upon the "Last Activity" field and the tier field, I can rather easily figure out who should be targetted.

In the case of the A producers, they should be contacted "Today - 30 days".

I created an S Control to create the tasks, but I struggled on the formatting of the date to be passed to the Last Activity field - I know that it needs to be in the format of YYYY-MM-DD, but I was never able to get the date format in the format that would work.

As a work around, I have the SControl prompt me for the date, for which I'll type "2007-02-23".  But, I'd much rather have it just be automatic (check out the red highlighted section in the code below).

I'll run this manually on a somewhat regular basis.

Any thoughts?
As always, thanks for the input.
RK

<html>

<head>

<script src="/soap/ajax/9.0/connection.js"></script>

<script>

var d = new Date(); //will give today's date
document.write(d+"<br>"); //displays today's date
d.setDate(d.getDate()-30); //subtract 30 days from today's date.  Ideally, this is passed against the "Last Activity Date"
document.write(d); //display what that date is
//alert("//alertingdate");
//alert(d);
var taskType = '012300000000PvkAAE';
var followUpTaskType = 'Outbound Call';
var followUpTaskSubject = 'Top 50 advisor not contacted in 30 days';
var followUpResults = 'Follow-Up';
var whatTaskDate = prompt('What is the date?',' ');
var followUpDate = {!Today};
var followUpTaskNotes = 'Call to make contact with one of your top 50 advisors - no contact has been made in the last 30 days';
var followUpTaskStatus = 'Not Started';
var followUpSubType = 'Tier 1 - Regular Contact';




function createTask() {
var queryContact = sforce.connection.query("Select Id, OwnerId from Contact where X2006_Rank_Within_Region__c > 0 and X2006_Rank_Within_Region__c < 51 and RecordTypeId = '0123000000005yGAAQ' and Known_Terminated__c = FALSE and ((lastactivitydate = null) or (lastactivitydate < "+whatTaskDate+"))limit 150");

//alert(queryContact);


contactsToBeTasked = queryContact.getArray("records");
//alert ("contactsToBeTasked");
//alert (contactsToBeTasked);
//var contactsToBeTaskedArray = new Array();


var contactsToBeTaskedArray= new Array();
//alert("Array Created");
//alert(contactsToBeTaskedArray);

var records = queryContact.getArray('records');

for (var i = 0; i < records.length; i++)
{
taskCreatedLineItem = contactsToBeTasked[i];
//alert(taskCreatedLineItem.get("Id"));
var neglectedContactTask = new sforce.SObject("Task");
//alert("DynaBean");
neglectedContactTask.set("RecordTypeId",taskType);
//alert("typeset");
neglectedContactTask.set("Type",followUpTaskType);
//alert ("Task Type Set");
neglectedContactTask.set("Subject",followUpTaskSubject);
//alert("SubSet");
neglectedContactTask.set("Status",followUpTaskStatus);
//alert("StatSet");
neglectedContactTask.set("Description",followUpTaskNotes);
//alert("CommSet");
neglectedContactTask.set("ActivityDate",new Date('{!Today}') );
//alert("dateset");
neglectedContactTask.set("OwnerId",taskCreatedLineItem .get("OwnerId"));
//alert("OwnerSet");
neglectedContactTask.set("WhoId",taskCreatedLineItem .get("Id"));
//alert("ConIDSet");
neglectedContactTask.set("Call_Sub_Type__c",followUpSubType );
//alert("SubType");
contactsToBeTaskedArray.push(neglectedContactTask);
//alert("Pushed");
}
var saveArrayResults = sforce.connection.create(contactsToBeTaskedArray);

}

</script>

</head>

<body onload="createTask();">

</body>

</html>
  • March 24, 2007
  • Like
  • 0
Hey all,
A new process is being developed within my sales organization where a group of people, on a daily basis, will manually create "Thank you" calls for another group of users.

Who the calls should be assigned to is based off of a custom field on the User Record of the Contact Owner (a relationship field).

So, since the calls are all essentially the same, I'm trying to allow the task-enteres to click a single link to create the task.

I can't seem to anything to query from the user table.  Here are my variable declaratoins.  As you will see near the bottom (for testing purposes)


var contactOwnerId = '{!Contact.OwnerId}';  //Here I'm grabbing the OwnerID from the Contact Record
alert (contactOwnerId );
alert("owenrID");
var firstTicketContactId = '{!Contact.Id}';
var firstTicketTaskSubject = 'First Ticket Follow-up Call';
var firstTicketResults = 'Follow-Up';
var firstTicketDate = {!Today};
var firstTicketTaskNotes = prompt('What are the comments for the task?',' ');
var firstTicketTaskStatus = 'Not Started';
//below is the query that where I'm trying to get the first name of the Contact Owner from the user table
var internalWholesalerId = sforceClient.Query("Select FirstName from User where Id = "'+contactOwnerId+"'");'
alert (internalWholesalerId);

So, even a simple query of pulling the first name from the user table returns a value of Undefined.

Thoughts?  As always, thanks for educating the ignorant (i.e. Me).

  • March 15, 2007
  • Like
  • 0
I am trying to add Activities that I have in excel in to Salesforce.  What do I use for the "Activity ID" field?  I tried using "New" but I get an error message that the object type is not supported.
Hey all,
I currently have a custom object that represents a piece of marketing material (i.e. a flyer, brouchere, etc).  These marketing materials need to be approved by the banks in which they are to be distributed, and to help disseminate the approval information, I created a relationship object that is displayed via a related list on the marketing Material object.

The user that maintains the marketing materials has 15 banks (which are accounts) that will automatically approve any material that we develop.  Rather than make her create 15 different relationship objects (called "Marketing Material Approvals") I developed an SControl to auto create the 15 relationship objects.

Essentially, I just took an SControl that would create a single relationship and copied it the code for the SControl multiple times - one for each bank.

THe SControl works, but it stops after creating the relationship for 2 or 3 banks.  I have found that if I move those banks that have the shortest names to the top of the code that it will create more of the relationship objects before it stops, leading me to beleive that I have hit a limit of some sort.

Any thoughts?   This would be quite the time saver for my user..

Thanks, as always.
LT


<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "Webster Bank"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    Linsco/Private Ledger (LPL)&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK="My First Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "My Second Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>
<script language="Javascript">
function redirect()
{parent.frames.location.replace('/a0F/e?retURL=%2F{!Marketing_Material__c.Id}&CF00N40000001UJyK=    "My Third Account Name"&CF00N40000001UJz3={!Marketing_Material__c.Name}&00N40000001UK0G=Approved&save=1');
}
redirect();
</script>

Message Edited by RK on 01-14-2007 06:23 AM

  • January 14, 2007
  • Like
  • 0