1 2 Previous Next 18 Replies Latest reply on Apr 27, 2018 12:34 PM by Dan Bontrager

    Is there a formula function to tell if a record was created from another object?

    Dan Bontrager

      Under an Incident record on the Details page and the Linked Change Request section, users can use the ‘Create and Link Change Request to Incident’ button to have a change request created from the incident.  We have a validation rule (on Incident, Problem, Change Request, and Task records) that requires a Queue be assigned at all times and that is preventing us from being able to use this button.  For reference, our validation rule on Change Request for this is:



      We need to keep this validation in place, but would also like to start using this button.  We have a few questions for the community based on this:

       

      (1) Is there a function that can be used in a validation formula that identifies if the record is created from this button or from another object’s record?  If there was, I think we could change the above formula to ignore the rule for new records created from another object.  Something like:
      BMCServiceDesk__Queue__c = "" &&
      (NOT(ISNEW()) && NOT([is record created from another object]))

       


      (2) If (1) is not possible, does anyone have a suggestion on how we could make the formula work with existing functions available today?

       

      (3) Is there a way to see the code behind the ‘Create and Link Change Request to Incident’ button?  Also, is there a way to modify this code (or create a new button) to set a Queue?  If so, maybe we could figure out a ‘pending’ queue to set change requests to that are created from this button.

       

      Thank for any replies!

        • 1. Re: Is there a formula function to tell if a record was created from another object?
          Amit Jaiswal

          Hi Dan,

           

          There is no way I can think of in which you can really detect if a "Button" was used to create a Change Request. Also you cannot access the code or modify it to set a Queue.

          However you can write a workflow to see if any change request is created and for which Queue is not already set, you assign the Default queue (or Pending Queue) to such a record.

           

          I also noticed that when you use the Create and Link button, the Initiator, Created By and the Owner field is set to the same logged in User. So may be that can be one way to detect if the Create and Link button was used. Although not full proof, but it can help validate to some extent.

           

          Thanks

          Amit

          • 2. Re: Is there a formula function to tell if a record was created from another object?
            Dan Bontrager

            Thanks for your reply Amit. Would it be possible to just have a copy of the code used for this button so I can see it and try to build my own button to replicate what it does plus set a Queue?  I think that is going to be my best route because as I show below, I cannot get a validation rule to work as needed.  If you can give me a validation rule suggestion based on what I have already tried below, I would give that a go too.  Thanks.

             

            I tried a formula modification to (1) create and link the change request from the incident button and (2) not require the Queue for the first manual save.  I came up with the below formulas, but none of them do both (1) and (2)…

             

            For the formulas

            BMCServiceDesk__Queue__c = "" &&

            NOT(ISNEW()) &&

            $User.Id <> BMCServiceDesk__FKInitiator__c &&

            $User.Id <> CreatedById  &&

            $User.Id <>  BMCServiceDesk__FKStaff__c

             

            BMCServiceDesk__Queue__c = "" &&

            NOT ISNEW() &&

            $User.Id <> BMCServiceDesk__FKInitiator__c &&

            $User.Id <> CreatedById &&

            $User.Id <> BMCServiceDesk__FKStaff__c

             

            BMCServiceDesk__Queue__c = "" &&

            NOT ISNEW() &&

            ISCHANGED(LastModifiedDate)

            these create and link the change request, but do not require the Queue for the first manual save.   I can set all the required fields the create misses and click save, but he Queue is not required when I need it to be.

             


            For the formulas
            BMCServiceDesk__Queue__c = "" &&

            NOT ISNEW ()

             

            BMCServiceDesk__Queue__c = "" &&

            NOT ISNEW() &&

            $User.Id = OwnerId

             

            NOT ISNEW() &&

            $User.Id = OwnerId

            these create the change request, but do not link it.  After the Please Wait screen is gone, you can go the Change Request object and see the new change, but there is no link established between it and the incident. Once you try to create the link manually, you get “Error: Queue is required at all times.”  Once a Queue is set (and the Queue validation does fire correctly with the first manual save), then the link can be manually created.

             


            For the formula

            BMCServiceDesk__Queue__c = "" &&
            $User.Id = OwnerId
            this does not let the button work as the “Queue is required at all times” validation fires while the button is processing. 

            • 3. Re: Is there a formula function to tell if a record was created from another object?
              Dan Bontrager

              Thanks for your reply Amit. Would it be possible to just have a copy of the code used for this button so I can see it and try to build my own button to replicate what it does plus set a Queue?  I think that is going to be my best route because as I show in my other reply, I cannot get a validation rule to work as needed.  If you can give me a validation rule suggestion based on what I have already tried below, I would give that a go too.  Thanks.

              • 4. Re: Is there a formula function to tell if a record was created from another object?
                Amit Jaiswal

                Hi Dan,

                 

                The copy of the button code will not help as it internally calls Remedyforce manage package code to set a queue.

                What you can possibly do instead is set a default Queue from a workflow for IsNew() records, but not sure that is what you really want.

                 

                Alternatively you can use the following formula in the validation rule:

                AND(ISBLANK(Owner:Queue.Id), NOT ISNEW())

                 

                The above will help achieve your initial create without a Queue and there on any manual or automated update would need a valid value in Queue.

                 

                Thanks

                Amit

                • 5. Re: Is there a formula function to tell if a record was created from another object?
                  Dan Bontrager

                  Thanks Amit for the reply.

                   

                  When I use that formula, it creates the change request, but does not link it.  After the Please Wait screen is gone, you can go the Change Request object and see the new change, but there is no link established between it and the incident. I think your formula is similar to one I mentioned above that I tried with the same result:

                  BMCServiceDesk__Queue__c = "" && NOT ISNEW ()

                  Do you have any other formula suggestions?

                   

                  I understand now regarding the button.  OK, lets say I want to create a custom button to do this 'create and link' action and populate IN Description to CR Description, IN Category to CR Category, Created By ID is user who clicked the button, and IN Queue to CR Queue.  Could you help me get started with how to do that...I have not created any custom buttons in Remedyforce and would be unsure where to start.  Thanks.

                  • 6. Re: Is there a formula function to tell if a record was created from another object?
                    Amit Jaiswal

                    Hi Dan,

                     

                    The formula is similar but not same. The BMCServiceDesk__Queue__c field may not be populated until the second save.

                    I recreated this in my env and it works.

                    Here are my steps which you can compare with yours.

                    1. Makes sure to create the validation rule I gave on Change Req

                    2. Open any Incident in Console and go the Details page

                    3. Scroll to the Linked Change Request Section and click on the "Create and Link CR to Incident" button

                    4. The CR record will get created and linked to the Incident which is why you see that new record appearing in the list

                    5. Click on the "Launch Console" record link to open that CR record.

                    6. In the CR form, hit Save without selecting anything in the Queue field.

                    7. The validation rule will get kicked in and ask to populate the Queue.

                    8. Click on the Details button to go to the details section and scroll to the "Linked Incidents" section. You will see the linked Incident information there too:

                     

                    If this is not happening in your environment, I will suggest checking for some other failures, create permission on Change Request object etc.

                     

                    For the button need, the whole logic is there in Apex controller code and not in the button. So unless you are comfortable programming in Apex, the button info is of not any use. The button script just acts as a mechanism to call the create and link process which is not in the button but in Apex code.

                     

                    Thanks

                    Amit

                    • 7. Re: Is there a formula function to tell if a record was created from another object?
                      Dan Bontrager

                      Amit –

                       

                      That makes sense on the formula.  I am using your suggestion for the validation now.  Also, I would not be comfortable for Apex coding (as I have never done it), so I’ll forget the custom button route.

                       

                      Thank you for posting your steps.  It’s at step 4 that my environment acts differently. 

                      1. Validation rule

                      2. & 3. Incident – Details - Create and Link Change Request to Incident button

                      At this point, after clicking the button, the Please Wait appears for a few seconds and once it is gone, no incident to change request link appears, even after a manual refresh.

                       

                      I don’t get any other failures or messages.  Within the Console, I can see the change request that this action created, but the link just does not get created, from either object.

                       

                      When you suggest checking create permission on Change Request, would that still apply since the change request is being created and just not linked?  I am willing to check and change any permission to get this to work.

                       

                      Thanks for all your help.

                       

                      Dan

                       

                      • 8. Re: Is there a formula function to tell if a record was created from another object?
                        Dan Bontrager

                        Amit -

                         

                        Do you have any suggestions for what permissions I should check to get this to work?  I have looked that the Profile and Permission Set in use and the Object Settings under them and nothing stood to me.

                         

                        Thanks for all your help.

                         

                        Dan

                        • 9. Re: Is there a formula function to tell if a record was created from another object?
                          Amit Jaiswal

                          Hi Dan,

                           

                          Apologies, it took long to revert.

                          Before we go any further, if you disable (deactivate) the validation rule, does the link gets created? I suspect that is the only different than the standard Remedyforce functionality.

                          If the link doesn't gets created even with the validation rule deactivated, then I will recommend to create a support case for the root cause analysis. Once this is fixed, you can activate the rule back and achieve your goal.

                           

                          Thanks

                          Amit

                          • 10. Re: Is there a formula function to tell if a record was created from another object?
                            Dan Bontrager

                            Amit -

                             

                            Yes, when I disable the validation rule, the link does get created.  So then my issue is the Queue is not required for the first manual save.  I can set all required fields the 'create and link' misses and click save, but the Queue is not required when I need it to be.

                             

                            Thanks.

                            Dan

                            • 11. Re: Is there a formula function to tell if a record was created from another object?
                              Amit Jaiswal

                              Hi Dan,

                               

                              Looks like there is something more in your org like a Workflow field update, Process builder flow update, a Roll-up summary field on the Incident or Change object etc. which is failing because of the validation rule to fail and preventing the "link" operation.

                               

                              If you cannot figure that out, I will suggest to log a support case and refer this discussion thread and get this investigated for the root cause.

                               

                              Thanks

                              Amit

                              • 12. Re: Is there a formula function to tell if a record was created from another object?
                                Dan Bontrager

                                OK, thanks Amit.  I marked your first reply as the correct answer to my original question about a formula function.  Thanks for all your help.

                                • 13. Re: Is there a formula function to tell if a record was created from another object?
                                  Dan Bontrager

                                  Amit, you were right about a roll-up summary field!...we had the following field on the Change Request object:

                                  We use this to verify that at least one incident is linked to the change if a custom field name Change Origin = Incident.  I added filter criteria to the roll-up summary field just to 'disable' it from running and everything worked as needed for the create and link button and the Queue being required on the first manual save!  So, now I just need to figure out how to still have this roll-up summary field work as we still need it...any suggestions for that?  Thanks again!

                                   

                                  Dan

                                  • 14. Re: Is there a formula function to tell if a record was created from another object?
                                    Dan Bontrager

                                    Amit -

                                     

                                    Can you think of any suggestions where I could keep using the roll-up summary field on the Incident Change Links object and have the button do the create and link action?  Could it maybe be considered as a defect that a roll-up summary field prevents this button from working?

                                     

                                    I can start a new discussion tread for this topic if you want me to.  Thanks!

                                    1 2 Previous Next