• Chris Fisher
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
Hi All,

I having some trouble taking 15 days off of a datetime field. 

    var day = prompt("Enter Callback day", "01");   
        var month = prompt("Enter Callback Month", "11");
        var year = prompt("Enter Callback Year", "2015");   
        var time = prompt("Enter Callback Time", "09:00");
        try
            {
            var taskToCreate = new sforce.SObject("Task");
              var datetime = year+"-"+month+"-"+day+"T"+time+":00Z";
            datetime - 15;
            taskToCreate.OwnerId = "{!$User.Id}";
            taskToCreate.WhoId = "{!Lead.Id}";
            taskToCreate.Subject = "Call";
            taskToCreate.ActivityDate = new Date();
            taskToCreate.Priority = "Normal";
            taskToCreate.Status = "Not Started";
            taskToCreate.IsReminderSet = true;
            taskToCreate.ReminderDateTime = mydatetime;
            result = sforce.connection.create([taskToCreate]);
            if(result[0].success == "true")
                {
                location.reload();
                }
            else
                {
                alert(
                "An Error has Occurred. Error: \r\n" +
                result[0].errors.message
                );
                }
            }
        catch(e)
            {
            alert(
            "An Un-expected Error has Occurred. Error: \r\n" +
                e
            );
            }

Basically its a customer button that will create a task, that will link to a lead, but we want the tast to pop up 15 days before the date entered. 

I think the problem is because "datetime" is a string and not a date time field. But how do i get it to be recognised as a datetime?

Thanks
Hi All,

I am trying to work out a way to populate a customer lead field by cross reference with a customer object, i will be doing this in APEX code as i believe its not possible as a workflow. 

Situation

We are using apex classes to create lead records using information sent into salesforce from a webserver.

SO, the apex code populates the below custom field
lead.abicode__c = 1234567


We then want lead.abigroup to update. As there is a large number of abicodes we have created a custom object ( abigroups16062014) and this contains around 30000 records showing two bits of information:

EG:
abigroups16062014.code = 1234567
abigroups16062014.group = 27

What i want to happen is when the lead is created, i would like a piece of code that will allow lead.abigroup__c to be populated with the corresponding group number from the custom object. 

so

find abigroup16062014.code where .code = l.abicode__c
then
l.abigroup__c = abigroup16062014.group

Does this make sense?


Hi All,

I having some trouble taking 15 days off of a datetime field. 

    var day = prompt("Enter Callback day", "01");   
        var month = prompt("Enter Callback Month", "11");
        var year = prompt("Enter Callback Year", "2015");   
        var time = prompt("Enter Callback Time", "09:00");
        try
            {
            var taskToCreate = new sforce.SObject("Task");
              var datetime = year+"-"+month+"-"+day+"T"+time+":00Z";
            datetime - 15;
            taskToCreate.OwnerId = "{!$User.Id}";
            taskToCreate.WhoId = "{!Lead.Id}";
            taskToCreate.Subject = "Call";
            taskToCreate.ActivityDate = new Date();
            taskToCreate.Priority = "Normal";
            taskToCreate.Status = "Not Started";
            taskToCreate.IsReminderSet = true;
            taskToCreate.ReminderDateTime = mydatetime;
            result = sforce.connection.create([taskToCreate]);
            if(result[0].success == "true")
                {
                location.reload();
                }
            else
                {
                alert(
                "An Error has Occurred. Error: \r\n" +
                result[0].errors.message
                );
                }
            }
        catch(e)
            {
            alert(
            "An Un-expected Error has Occurred. Error: \r\n" +
                e
            );
            }

Basically its a customer button that will create a task, that will link to a lead, but we want the tast to pop up 15 days before the date entered. 

I think the problem is because "datetime" is a string and not a date time field. But how do i get it to be recognised as a datetime?

Thanks
Hi All,

I am trying to work out a way to populate a customer lead field by cross reference with a customer object, i will be doing this in APEX code as i believe its not possible as a workflow. 

Situation

We are using apex classes to create lead records using information sent into salesforce from a webserver.

SO, the apex code populates the below custom field
lead.abicode__c = 1234567


We then want lead.abigroup to update. As there is a large number of abicodes we have created a custom object ( abigroups16062014) and this contains around 30000 records showing two bits of information:

EG:
abigroups16062014.code = 1234567
abigroups16062014.group = 27

What i want to happen is when the lead is created, i would like a piece of code that will allow lead.abigroup__c to be populated with the corresponding group number from the custom object. 

so

find abigroup16062014.code where .code = l.abicode__c
then
l.abigroup__c = abigroup16062014.group

Does this make sense?