• JJJenkins
  • NEWBIE
  • 55 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 37
    Replies

I'm having trouble writing a validation rule where I would compare now() to a set time.

 

What I'm trying to do is say when a custom date field is changed if the time the change is happening is after 12 noon to fire the validation.

 

Here are the different ways I've attempted this:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> DATETIMEVALUE(TEXT(YEAR(TODAY()))+"-" +TEXT(MONTH(TODAY()))+"-" +TEXT(DAY(TODAY()))+" "+"12"+ ":00"+":00")
)

 I've also tried:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> VALUE(MID(TEXT(NOW()),12,2))>12
)

 Any help would be appreciated.

 

Thanks!

I have a visualforce page that use javascript remoting that is put inline into a standard page layout.

 

When I use the page outside of the standard page layout it works fine but when I try to use it inside of the standard layout I receive this error: 

 

Unsafe JavaScript attempt to access frame with URL https://cs7.salesforce.com/a1hM00000008eaY from frame with URL https://c.cs7.visual.force.com/servlet/servlet.Integration?lid=066M00000008kBb&ic=1. Domains, protocols and ports must match.

 

Anyone experience this before - what does this error mean?

I have a button on a standard page layout that launches a vf page through javascript:

{!requireScript('/soap/ajax/24.0/connection.js')}
var windowRef;
var intervalId = 0;
 
setTimeout(checkToOpenWindow, 2*1000);
 
function checkToOpenWindow()
{
windowRef = window.open("https://cs7.salesforce.com/apex/AcctUpdate?id={!Account.Id}","menubar=1,resizable=1,width=800,height=250");
checkWindowStatus();
}
function checkWindowStatus()
{
intervalId = setInterval(checkAndCloseWin, 5*1000);
}
function checkAndCloseWin()
{
if(windowRef.closed)
   {
    clearInterval(intervalId);
    window.parent.location.href = window.parent.location.href;
  }
}

 Then in the VF page that launches I have a button that I would like to do a submit and save function.  I'm using the account standard controller and the standard {!save} functionality then calling some js onclick.  All of the javascript works except for window.close().

 

Here is the breakdown of the vf page and the JS:

<apex:page standardController="Account" extensions="AcctTaxonomy" sidebar="false" showHeader="false">
    
    <apex:form >
    <div id="Acct">
        //THERES A BUNCH OF VF BEFORE THIS
        <apex:commandbutton action="{!save}" value="Submit & Save" onclick="submitSelections()"/>
    </div>
    
    <script type="text/javascript">
        beenFocused = true;
               
                
       //THERE ARE OTHER JS FUNCTIONS I LEFT OUT FOR BREVITY
        function submitSelections()
           {
               serviceSelect();
               attributeSelect();
               window.close();          
           }   
    </script>
    </apex:form>
</apex:page>

 any thoughts?

I have this trigger:

trigger MultiAssignPO on Assigned_To__c (after insert, after update) {
   set<id> PoIds = new set<id>();
   
   //lets get all of the IDs of the POs we will work with
   for (Assigned_To__c AsToObj :Trigger.new)
       {
           PoIds.add(AsToObj.Purchase_Order__c);
       }
   //now lets get a list of POs we will work with
   List<Purchase_Order__c> relatedPOs = [SELECT id, Assigned_To_Multi__c
                                            FROM Purchase_Order__c
                                            WHERE id in :PoIds]; 
       //iterate over the list of POs                                     
       for(Purchase_order__c p :relatedPOs)
           {
               string name ='';
               
               //iterate over the assigned to
               for(Assigned_To__c a :trigger.new)
                   {
                       //now we check if the assigned to belongs to the PO we are iterating over in the first loop, if it is, add it to the string name
                       if(a.Purchase_Order__c == p.id)
                           {
                               if(a.Assigned_To__r.Full_Name__c !=null)
                                   {
                                       name += a.Assigned_To__r.Full_Name__c + ' ; ';
                                   }    
                           }
                   }
                //set the value of the multi-assigned in the PO   
                p.Assigned_To_Multi__c = name;
           }
           
           //make a DML statement to update the POs
           update relatedPOs;

}

 But when it does the update it is inserting "null" as the value - it isn't pulling the name value from the user lookup field called Assigned_To__c.

 

Thoughts?

I have two custom objects.

 

Order and Assigned

 

Assigned has a lookup to order and a lookup to the user.

 

On the order object have a text area field I want to populate a list of assignees from the assigned object user lookup.

 

How do I do this?

 

Thanks,

I'm trying to create an approve button that I can put on a list view where multiple records can be selected to be approved or rejected.

 

I was going to create two seperate buttons for this.  One for Approve Selected and another Reject Selected.

 

The button, I believe, needs to call a VF page that invokes a class.  Has anyone done this or have any insight?

 

I've only done java buttons that have actions before and I'm stuck on how to get started.  I've done VF and classes but not sure how to call an approval process.

I'm having issues with not getting this to fire all of the time:

 

trigger InsertACHupdateDate on Account (before update) { 
   
    map<id,account> oldMap = new map<id,account>();
    map<id,account> newMap = new map<id,account>();
    for(Account acctOld : trigger.old)
        {                     
                oldMap.put(acctOld.id, acctOld);              
        }
    for(account acctNew : trigger.new)
        {     
                newMap.put(acctNew.id, acctNew);              
        }
        
    for(account a :trigger.new)
        {
            boolean updateCheck = false;
            account oldA = oldMap.get(a.id);
            account newA = newMap.get(a.id);            
           
            if(oldA.Routing_Number_enc__c != null && newA.Routing_Number_enc__c != null)
                if(oldA.Routing_Number_enc__c != newA.Routing_Number_enc__c)
                    updateCheck = true;
               
            if(oldA.Account_Number__c != null && newA.Account_Number__c != null)    
                if(oldA.Account_Number__c != newA.Account_Number__c)
                    updateCheck = true;
                
            if(oldA.BillingStreet!=newA.BillingStreet)
                updateCheck = true;
                
            if(oldA.BillingCity!=newA.BillingCity)
                updateCheck = true;
                
            if(oldA.BillingState!=newA.BillingState)
                updateCheck = true;
                
            if(oldA.BillingPostalCode!=newA.BillingPostalCode)
                updateCheck = true;
                
            if(oldA.BillingCountry!=newA.BillingCountry)
                updateCheck = true;
                
            if(oldA.Payable_To__c!=newA.Payable_To__c)
                updateCheck = true;
            
            if(updateCheck)
            {
                a.Last_ACH_Update__c = System.Today();
            }     
        }                                             
}

 It will fire if there is info in the field and it changes but not when it is first filled in for the Account# field and Routing field.

 

Thanks,

I have a workflow rule that populates a status field but I don't want it to fire if 3 options are the current values or if the options that excluded are manually selected.  Based on different variations I can either get the field to populate, or have the field not change but if I remove the selection then the rule won't populate the appropiate status.  Below is the current workflow which is not populating the status but keeping the Values.  Any Help?

AND( 
(OR ( 
TODAY() >= Targeted_Close_Date__c -15, 
TODAY() <= Targeted_Close_Date__c+15 
)), 
(OR ( 
ISPICKVAL(Account_Status__c,"Active – Delayed"), 
ISPICKVAL(Account_Status__c,"Inactive – Out of Business "), 
ISPICKVAL(Account_Status__c,"Inactive – Regrettable Loss"), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Active – Delayed"))), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Inactive – Out of Business"))), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Inactive – Regrettable Loss")))) 
) 
)

 

 

I have two encrypted fields and when either of them change/get updated I want a date stamp to populate the date of change, essentially  Today(), I can't do this via workflow as encrypted fields aren't available to use in Workflow.

 

I'm kind of stuck on where to start as I'm still learning.  

 

I understand I need to use trigger.old and trigger.new to compare values of the fields but how do I do that across two fields?  Or do I have to write two triggers?  The only triggers I've done before update a value it is checking.  how do I tell it to insert todays date into a field?

I've created a workflow rule that updates everytime the owner is changed.  The field update is the field (# of times transferred) so the formula I've used is #_of_time_Transferred__c +1 so that everytime this workflow fires this field updates.  But it is not working?  Is this possible with workflow or do I need to do it with a trigger?

 

Thanksm

I'm still learning apex so I wanted to see if this was even possible.

 

I have a user look up field on the lead that I want filled in automatically with the previous owner when the lead owner is changed.

 

Thoughts?

 

Thanks everyone!

I'm playing around with css and visualforce.  I believe this could be very useful but I'm having an issue with where to place the tags.

 

I have a static resource loaded called tablayoutCSS that is a zip file with some images and css.

 

One of the images is a background image we want to use for the whole page.  Where and how do I place this in visualforce?

 

Thanks,

We are using the tabbed layout and want to be able to have the default tab change based on the profile of the user.

 

Theoretically it would look something like this

<apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" 
selectedTab="IF($Profile.Name=='Inside Sales',salesinfo,(IF($Profile.Name=='Accounting',Financials,dealinfo)))">

 Thinking I should do this in apex.  Anyone have any experience with this?

 

Thanks,

Hey Everyone - 

 

So I want to put in place a validation rule where they can't add to the field if it's blank but they can delete it.

 

 

OR(
(AND(PRIORVALUE(ISBLANK(field__c),
ISCHANGED(field__c)), (AND(PRIORVALUE(ISBLANK(field2__c),
ISCHANGED(field2__c)) )

 But it is telling me I have an error at the end of line 2 that I'm missing ")".

 

Suggestions?

 

So this is my first trigger going into production.  I've gone through the workbooks but I have come to a stop as I'm not sure where I'm going wrong.  With the trigger I'm trying to populate a lookup field on the opportunity with the current account owner that is associated to the opportunity.

 

Here is the code:

 

trigger AccountOwner on Opportunity (after update) {

//update opportunity with current account owner
List<Opportunity> AccountOwner = 
[SELECT Account.OwnerId, Acct_Owner__c FROM Opportunity FOR UPDATE];

    for (Opportunity o: AccountOwner){
        if(o.Acct_Owner__c <> Account.OwnerId){
        o.Acct_Owner__c=Account.OwnerId;
        }
    }
    update AccountOwner;
}

 

 

I'm getting a compile error at line 9 column 9 Illegal assignment from Schema.SObjectField to Id.

 

Suggestions/ help?  It doesn't have to be a look up field, it can be changed to text if that is the issue.

 

thanks,

I have picklist called "Months to Expiration" that lists 1 Month, 2 Months, so on and so on to 12 months.  I want to calculate an expiration date field from another date field (Activation Date).

 

Has anyone done this?  I can't just use +30, +60 etc because months aren't truly structured that way.

 

Any help is appreciated.

 

Thanks,

Hey Everyone - 

 

I'm trying to create a validation rule that does the following:

If any of these three % fields have data but the sum of the three fields does not equal 100% I want the record to not be able to save.

AND( 
(OR( 
X1st_Payment__c>0.0, 
X2nd_Payment__c>0.0, 
X3rd_Payment__c>0.0)), 
(X1st_Payment__c+X2nd_Payment__c+X3rd_Payment__c<>1.0) 
)

 That is what I have as of right now but the validation doesn't trigger.

 

Any insights?

 

Thanks,

 

Hey Everyone - 

 

I have a workflow rule that assigns a task to a member of oppty selling team.  For some reason then the rule triggers it is assigning the task to the owner if there isn't a "team member" on the specific opportunity.  I just want it to  not fire if this is true but it isn't an option in the workflow rule setup.

 

Any help would be appreciated.

 

Thanks,

Has anyone experienced a loss of functionality after deploying the change set from sandbox to prod?

 

I pushed over a VF page with a lot of "rendered" attributes" and none of them are working?  Two formula fields broke also.

 

Any experience with this or suggestions?

 

Thanks,

I have a visualforce page that contains dependent picklists but I want to have inline editing enabled.  When I do this I get a VF error that says inline editing isn't available for dependent picklists.

 

Does anyone know a workaround?

I'm having trouble writing a validation rule where I would compare now() to a set time.

 

What I'm trying to do is say when a custom date field is changed if the time the change is happening is after 12 noon to fire the validation.

 

Here are the different ways I've attempted this:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> DATETIMEVALUE(TEXT(YEAR(TODAY()))+"-" +TEXT(MONTH(TODAY()))+"-" +TEXT(DAY(TODAY()))+" "+"12"+ ":00"+":00")
)

 I've also tried:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> VALUE(MID(TEXT(NOW()),12,2))>12
)

 Any help would be appreciated.

 

Thanks!

I have a visualforce page that use javascript remoting that is put inline into a standard page layout.

 

When I use the page outside of the standard page layout it works fine but when I try to use it inside of the standard layout I receive this error: 

 

Unsafe JavaScript attempt to access frame with URL https://cs7.salesforce.com/a1hM00000008eaY from frame with URL https://c.cs7.visual.force.com/servlet/servlet.Integration?lid=066M00000008kBb&ic=1. Domains, protocols and ports must match.

 

Anyone experience this before - what does this error mean?

I have two custom objects.

 

Order and Assigned

 

Assigned has a lookup to order and a lookup to the user.

 

On the order object have a text area field I want to populate a list of assignees from the assigned object user lookup.

 

How do I do this?

 

Thanks,

I'm trying to create an approve button that I can put on a list view where multiple records can be selected to be approved or rejected.

 

I was going to create two seperate buttons for this.  One for Approve Selected and another Reject Selected.

 

The button, I believe, needs to call a VF page that invokes a class.  Has anyone done this or have any insight?

 

I've only done java buttons that have actions before and I'm stuck on how to get started.  I've done VF and classes but not sure how to call an approval process.

I'm having issues with not getting this to fire all of the time:

 

trigger InsertACHupdateDate on Account (before update) { 
   
    map<id,account> oldMap = new map<id,account>();
    map<id,account> newMap = new map<id,account>();
    for(Account acctOld : trigger.old)
        {                     
                oldMap.put(acctOld.id, acctOld);              
        }
    for(account acctNew : trigger.new)
        {     
                newMap.put(acctNew.id, acctNew);              
        }
        
    for(account a :trigger.new)
        {
            boolean updateCheck = false;
            account oldA = oldMap.get(a.id);
            account newA = newMap.get(a.id);            
           
            if(oldA.Routing_Number_enc__c != null && newA.Routing_Number_enc__c != null)
                if(oldA.Routing_Number_enc__c != newA.Routing_Number_enc__c)
                    updateCheck = true;
               
            if(oldA.Account_Number__c != null && newA.Account_Number__c != null)    
                if(oldA.Account_Number__c != newA.Account_Number__c)
                    updateCheck = true;
                
            if(oldA.BillingStreet!=newA.BillingStreet)
                updateCheck = true;
                
            if(oldA.BillingCity!=newA.BillingCity)
                updateCheck = true;
                
            if(oldA.BillingState!=newA.BillingState)
                updateCheck = true;
                
            if(oldA.BillingPostalCode!=newA.BillingPostalCode)
                updateCheck = true;
                
            if(oldA.BillingCountry!=newA.BillingCountry)
                updateCheck = true;
                
            if(oldA.Payable_To__c!=newA.Payable_To__c)
                updateCheck = true;
            
            if(updateCheck)
            {
                a.Last_ACH_Update__c = System.Today();
            }     
        }                                             
}

 It will fire if there is info in the field and it changes but not when it is first filled in for the Account# field and Routing field.

 

Thanks,

I have a workflow rule that populates a status field but I don't want it to fire if 3 options are the current values or if the options that excluded are manually selected.  Based on different variations I can either get the field to populate, or have the field not change but if I remove the selection then the rule won't populate the appropiate status.  Below is the current workflow which is not populating the status but keeping the Values.  Any Help?

AND( 
(OR ( 
TODAY() >= Targeted_Close_Date__c -15, 
TODAY() <= Targeted_Close_Date__c+15 
)), 
(OR ( 
ISPICKVAL(Account_Status__c,"Active – Delayed"), 
ISPICKVAL(Account_Status__c,"Inactive – Out of Business "), 
ISPICKVAL(Account_Status__c,"Inactive – Regrettable Loss"), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Active – Delayed"))), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Inactive – Out of Business"))), 
(AND (ISCHANGED(Account_Status__c),ISPICKVAL(Account_Status__c,"Inactive – Regrettable Loss")))) 
) 
)

 

 

I have two encrypted fields and when either of them change/get updated I want a date stamp to populate the date of change, essentially  Today(), I can't do this via workflow as encrypted fields aren't available to use in Workflow.

 

I'm kind of stuck on where to start as I'm still learning.  

 

I understand I need to use trigger.old and trigger.new to compare values of the fields but how do I do that across two fields?  Or do I have to write two triggers?  The only triggers I've done before update a value it is checking.  how do I tell it to insert todays date into a field?

I've created a workflow rule that updates everytime the owner is changed.  The field update is the field (# of times transferred) so the formula I've used is #_of_time_Transferred__c +1 so that everytime this workflow fires this field updates.  But it is not working?  Is this possible with workflow or do I need to do it with a trigger?

 

Thanksm

I am trying to create a field on a master object that is a concatenation of a field on a detail object when certain things are true.

 

In this particular case, "Student__c" is the master object and "Student_Call_Logs__c" is the detail object.  I'd like to pull the notes & dates field from the call log when the call is of a particular type... and stick this info into 1 field that would look like

 

"date -- note

 date -- note

 date -- note"

 

So far I have...

 

 

trigger CountRelatedCallLogs on Student_Call_Log__c (after insert, after update) { //define parameters //Student__c is the master object; Student_Call_Logs__c is the detail object String sid = null, note = null, techlogs = null, temp_note = null, temp_date = null; Integer i = null, counter=null; Set<Id> techlogids = new set<Id>(); techlogs = ''; counter = 0; Student_Call_Log__c [] scl = Trigger.new; sid = scl[0].Related_Student__c; Student_Call_Log__c [] relatedCLogs =[select id from Student_Call_Log__c where Related_Student__c = :sid and Call_Type__c = 'Avanza Tech Support' order by Call_Date_Time__c DESC]; for (Student_Call_Log__c cl : relatedCLogs) { temp_note = relatedCLogs[counter].Note__c; temp_date = relatedCLogs[counter].Call_Date__c techlogs = techlogs + temp_date + ' -- ' + temp_note + '\n'; counter = counter+1; }

 

So, I seem to be stuck in that I can't put the info into one 1 field AND I don't know how to pull the date and stick that into a text field.

 

Thanks!

 

 

  • February 11, 2010
  • Like
  • 0