• Shamrock Snowman
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 12
    Replies
I am trying to use a button with onclick javascript to pass today's date into an existing date field, but I get the error message "12/23/2013 is not a valid value for the type xsd:date".  What is the correct way to pass today's date?  My code is below.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} /*call the ajax connection*/
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

var currentDate= new Date();
var month = currentDate.getMonth() + 1;
var day = currentDate.getDate();
var year = currentDate.getFullYear();
var today = (month + "/" + day + "/" + year);

var requestFetchInstall= new sforce.SObject("P4_Contract__c"); /*Initialize a new
sobject to work with, this would need to be changed whatever custom object */
requestFetchInstall.Id = "{!P4_Contract__c.Id}"; /* set var to the record id we are working on */
requestFetchInstall.Fetch_Install_Requested__c =(today); /*set a custom field, you would have to rename it to yours, to the value desired, or any field you choose */
result = sforce.connection.update([requestFetchInstall]); /* update the record we initalized with the id *


window.location.reload(); /* reload the page */

I am considering the concept of creating a managed package specifically for one client, as opposed to selling it on the AppExchange.  The reason is so that we can build in functionality using Apex code that is not otherwise available on the client's Professional Edition org.


With unlisted managed packages, is the security review still required?  If so, would it be free or at a cost, in this situation?

 

Thank you.

Dave

I have a ChatUp trigger that posts to a parent object feed when a particular field in the child object is updated.  I copied a test class from a similar trigger, but the one I copied from is based on INSERTING records vs UPDATING them.  How can I modify my test class to not only insert the child object records (Drug Test), but then to UPDATE those records so that the trigger fires? 

 

Here is the trigger:  the Result__c field must have been updated in order to post to the Chatter feed.

 

trigger ChatterDrugTestResultChatUp on Drug_Test__c (after update) {
for (Drug_Test__c newDrugTest : Trigger.new) {
Drug_Test__c oldDrugTest = Trigger.oldMap.get (newDrugTest.Id);
if (oldDrugTest.Result__c != newDrugTest.Result__c){
ChatterUpHelper helper = new ChatterUpHelper();
helper.chatterUp(Trigger.new);
}
}
}

 

 

Here is the TEST CLASS I have so far:

 

@isTest
public class ChatterUpTestDrugTest {
static testMethod void testChatterUpOrder(){
Date today = date.today();
LIST<Drug_Test__c> drugTestList = new LIST<Drug_Test__c>();
Chatter_Up__c settingsChatter = createChatterUpConfig();/*new Chatter_Up__c(Name = 'Drug Test',
Chatter_Post_Body__c = 'A Drug Test result has been posted to this order. Click the link below to view.',
Parent_ID_Field__c = 'Order__c',
Object_API_Name__c = 'Drug_Test__c');*/
insert settingsChatter;

Org_Specific_Values__c settingsOrg = new Org_Specific_Values__c(Name = 'test',
Bypass_Triggers_For_Data_Loading__c = False);
insert settingsOrg;
Tax_Schedule__c t = new Tax_Schedule__c(County__c = 'All State',
State__c = 'Alabama');
insert t;

Account a = new Account(Name = 'Test Account',
Type = 'Prospect',
BillingStreet = 'test',
BillingCity = 'test',
BillingState = 'test',
BillingPostalCode = 'test'
);
insert a;

Contact c = new Contact(LastName = 'Test Contact',
AccountId = a.Id);

Order__c o = new Order__c(Name = 'Test Order',
Client_Name__c = a.Id,
Contact__c = c.Id,
Account_Manager__c = UserInfo.getUserId(),
Status__c = 'Inquiry',
orderType__c = 'New Project',
workState__c = 'Alabama',
Trade__c = 'a1yA0000000EN9z',
Tax_Schedule__c = t.Id,
Requested_Headcount__c = 1,
Project_Start_Date__c = today,
Estimated_Project_End_Date__c = date.newInstance(today.year(),today.month(),28),
Requested_Start_Time__c = '7:00 AM',
Candidate_Submit_Date__c = today
);
insert o;

for(Integer i=0; i < 100; i++){
Drug_Test__c dt = new Drug_Test__c(Order__c = o.Id,
Employee_Name__c = 'a1eA0000000dBmY',
Date_of_Drug_Test__c = today,
Vendor__c = 'Concentra',
Test_Type__c = 'Urine (DOT)',
Number_of_Drugs_Tested__c = '5-Panel');
drugTestList.add(dt);
}
test.startTest();
insert drugTestList;
test.stopTest();
LIST<FeedItem> orderFeed = [SELECT ParentId FROM FeedItem WHERE ParentId = :o.Id];
System.assertEquals(100,orderFeed.size());
}

static private Chatter_Up__c createChatterUpConfig(){
Chatter_Up__c setting = new Chatter_Up__c();

setting.Name = 'Drug Test';
setting.Chatter_Post_Body__c = 'A Drug Test result has been posted to this order. Click the link below to view.';
setting.Parent_ID_Field__c = 'Order__c';
setting.Object_API_Name__c = 'Drug_Test__c';

return setting;
}
}

 

 

I am hoping for some code that I can use in a Custom Button.  It is for the Detail Page of a custom object called Orders.  I have a text field called Recruiter In Charge, and I want to have that field automatically filled in with the user's name (first and last) when he clicks the Button on the Detail Page.

 

Any help would be greatly appreciated!

 

 

I have a Vf page that contains search results of candidate names.  I am looking to create a button on this page that will send the candidate names (as links to their records) into an embedded Vf page on another custom object (called Orders).  Then, how do I code the embedded page to display these names?  

 

I'm not very literate in Apex or VisualForce, but any help or direction would be greatly appreciated.

I have a custom activity field called Activity Notes (255 text area) and I am looking to create a trigger that will automatically copy text from an activity's Comments field into that same activity's Activity Notes field.

 

Assuming that

  1. the Activity Notes field was otherwise blank for this activity (it will be), and 
  2. the Comment is <= 255 characters so that it will fit.  Ideally, even if the comment is longer the trigger would just copy over the first 255 characters of it.

 

Does anyone have any tips for such a trigger?

 

Thanks.

Does anyone know the best way to quickly and easily compare an external list of names or companies against my existing Salesforce database, without searching for each one separately?

My sales team comes up with lists from conferences, but we already have tens of thousands of leads and prospects to check them against.

 

Thanks.

I am considering the concept of creating a managed package specifically for one client, as opposed to selling it on the AppExchange.  The reason is so that we can build in functionality using Apex code that is not otherwise available on the client's Professional Edition org.


With unlisted managed packages, is the security review still required?  If so, would it be free or at a cost, in this situation?

 

Thank you.

Dave

I have a ChatUp trigger that posts to a parent object feed when a particular field in the child object is updated.  I copied a test class from a similar trigger, but the one I copied from is based on INSERTING records vs UPDATING them.  How can I modify my test class to not only insert the child object records (Drug Test), but then to UPDATE those records so that the trigger fires? 

 

Here is the trigger:  the Result__c field must have been updated in order to post to the Chatter feed.

 

trigger ChatterDrugTestResultChatUp on Drug_Test__c (after update) {
for (Drug_Test__c newDrugTest : Trigger.new) {
Drug_Test__c oldDrugTest = Trigger.oldMap.get (newDrugTest.Id);
if (oldDrugTest.Result__c != newDrugTest.Result__c){
ChatterUpHelper helper = new ChatterUpHelper();
helper.chatterUp(Trigger.new);
}
}
}

 

 

Here is the TEST CLASS I have so far:

 

@isTest
public class ChatterUpTestDrugTest {
static testMethod void testChatterUpOrder(){
Date today = date.today();
LIST<Drug_Test__c> drugTestList = new LIST<Drug_Test__c>();
Chatter_Up__c settingsChatter = createChatterUpConfig();/*new Chatter_Up__c(Name = 'Drug Test',
Chatter_Post_Body__c = 'A Drug Test result has been posted to this order. Click the link below to view.',
Parent_ID_Field__c = 'Order__c',
Object_API_Name__c = 'Drug_Test__c');*/
insert settingsChatter;

Org_Specific_Values__c settingsOrg = new Org_Specific_Values__c(Name = 'test',
Bypass_Triggers_For_Data_Loading__c = False);
insert settingsOrg;
Tax_Schedule__c t = new Tax_Schedule__c(County__c = 'All State',
State__c = 'Alabama');
insert t;

Account a = new Account(Name = 'Test Account',
Type = 'Prospect',
BillingStreet = 'test',
BillingCity = 'test',
BillingState = 'test',
BillingPostalCode = 'test'
);
insert a;

Contact c = new Contact(LastName = 'Test Contact',
AccountId = a.Id);

Order__c o = new Order__c(Name = 'Test Order',
Client_Name__c = a.Id,
Contact__c = c.Id,
Account_Manager__c = UserInfo.getUserId(),
Status__c = 'Inquiry',
orderType__c = 'New Project',
workState__c = 'Alabama',
Trade__c = 'a1yA0000000EN9z',
Tax_Schedule__c = t.Id,
Requested_Headcount__c = 1,
Project_Start_Date__c = today,
Estimated_Project_End_Date__c = date.newInstance(today.year(),today.month(),28),
Requested_Start_Time__c = '7:00 AM',
Candidate_Submit_Date__c = today
);
insert o;

for(Integer i=0; i < 100; i++){
Drug_Test__c dt = new Drug_Test__c(Order__c = o.Id,
Employee_Name__c = 'a1eA0000000dBmY',
Date_of_Drug_Test__c = today,
Vendor__c = 'Concentra',
Test_Type__c = 'Urine (DOT)',
Number_of_Drugs_Tested__c = '5-Panel');
drugTestList.add(dt);
}
test.startTest();
insert drugTestList;
test.stopTest();
LIST<FeedItem> orderFeed = [SELECT ParentId FROM FeedItem WHERE ParentId = :o.Id];
System.assertEquals(100,orderFeed.size());
}

static private Chatter_Up__c createChatterUpConfig(){
Chatter_Up__c setting = new Chatter_Up__c();

setting.Name = 'Drug Test';
setting.Chatter_Post_Body__c = 'A Drug Test result has been posted to this order. Click the link below to view.';
setting.Parent_ID_Field__c = 'Order__c';
setting.Object_API_Name__c = 'Drug_Test__c';

return setting;
}
}

 

 

I am hoping for some code that I can use in a Custom Button.  It is for the Detail Page of a custom object called Orders.  I have a text field called Recruiter In Charge, and I want to have that field automatically filled in with the user's name (first and last) when he clicks the Button on the Detail Page.

 

Any help would be greatly appreciated!

 

 

I have a Vf page that contains search results of candidate names.  I am looking to create a button on this page that will send the candidate names (as links to their records) into an embedded Vf page on another custom object (called Orders).  Then, how do I code the embedded page to display these names?  

 

I'm not very literate in Apex or VisualForce, but any help or direction would be greatly appreciated.

Does anyone know the best way to quickly and easily compare an external list of names or companies against my existing Salesforce database, without searching for each one separately?

My sales team comes up with lists from conferences, but we already have tens of thousands of leads and prospects to check them against.

 

Thanks.

I was hoping that SFDC would add time based rule evaluation to the workflow capabilities.  That is, to run workflow rules without requiring the record to be modified first to trigger the rule.
 
My example is we allow some accounts be have a protected status as long as they have certain activity in a certain time period.  I've created the field that shows the days since said qualified activity occured, I have a workflow that will change the protected status based on the value in that qualified activity age field.
 
However, the rule only runs when someone modifies the account, so accounts can be falsely protected simply by not editing them.
 
I'm trying to find a way to make this rule run periodically without the modification.
 
Any suggestions?
 
Thanks,
 
Michael