none
Make a record in one Entity Inactive when a value is changed in another Entity of the same record.

    Question

  • I have two entities, Bookings and Discharge. 

    When a record is created in Bookings, it automatically creates a record in Discharge. Discharge 
    has an additional field that is a drop down with four options. 

    I want a functionality where when any one of the values in drop down is chosen, the similar record in Bookings 
    should shift from "Active" view to a default view which I have created by the name of "Processed" in Bookings.

    What I have in mind is to create a hidden field in Bookings that is populated when I choose one of the options from Discharge drop down and based on that field the record should shift the view in Bookings. But how do I populate the hidden field? Workflow is not giving me that option or maybe I am doing something wrong. 

    Help?


    Tuesday, August 20, 2013 4:46 PM

Answers

  • Hi,

    You can create 1:N relationship between Booking and Discharge. You can hide the Discharge left navigation from the booking and can remove the Look up field of booking from discharge so that nobody can create more than one discharge for booking.

    OR another option is

    - Create a Custom field of type nvarchar in Discharge entity.

    - After creating the Discharge for booking through workflow set the Booking Id in custom field.

    - The custom field will not be available on Discharge entity form.

    - We can use the Guid stored in this custom field to update the booking. we can retrieve the booking where Booking id=Custom field id and update the statue of booking.

    Hope this helps!

    Thanks!

    • Marked as answer by Hamzak Wednesday, August 21, 2013 1:13 PM
    Wednesday, August 21, 2013 10:24 AM

All replies

  • Hi,

    Is there any relationship between Booking and Discharge? You can create plugin/workflow on update of 4 fields on Discharge entity that will find the Similar booking record and will populate the hidden field on Booking

    hope this helps!

    Thanks!


    • Edited by KalimK Tuesday, August 20, 2013 6:06 PM
    Tuesday, August 20, 2013 6:06 PM
  • function user()

              {

              var C = new Array;

              C= Xrm.Page.getAttribute('ownerid').getValue();

              var b= C[0].name;

              if(b=='Your User Name')

                            {

                            Xrm.Page.getControl('Bookings field name').setDisabled(false);

                            }

              else

                           {

                           Xrm.Page.getControl('Bookings field name').setDisabled(true);

                           }

              }

    By calling the above function you will be able to hide the desired field for other users but you may access that field.

    Regards

    Manjunath

    Wednesday, August 21, 2013 5:09 AM
  • you can create a workflow to to deactive record to change of the field 

    ms crm

    Wednesday, August 21, 2013 6:01 AM
  • I have not created any particular relationship. The only thing is that there is already a workflow that created a record in Discharge when a record in Bookings is created. Now I want a workflow where when a person is discharged from the entity Discharge the similar record in Bookings should be shifted to my custom view. 

    How do I make a relationship between these records in two entities to make sure that the same record is processed to my custom view after the workflow.?
    • Edited by Hamzak Wednesday, August 21, 2013 9:44 AM
    Wednesday, August 21, 2013 9:34 AM
  • I have not created any particular relationship. The only thing is that there is already a workflow that created a record in Discharge when a record in Bookings is created. Now I want a workflow where when a person is discharged from the entity Discharge the similar record in Bookings should be shifted to my custom view. 

    How do I make a relationship between these records in two entities to make sure that the same record is processed to my custom view after the workflow.?
    Wednesday, August 21, 2013 9:44 AM
  • Hi,

    You can create 1:N relationship between Booking and Discharge. You can hide the Discharge left navigation from the booking and can remove the Look up field of booking from discharge so that nobody can create more than one discharge for booking.

    OR another option is

    - Create a Custom field of type nvarchar in Discharge entity.

    - After creating the Discharge for booking through workflow set the Booking Id in custom field.

    - The custom field will not be available on Discharge entity form.

    - We can use the Guid stored in this custom field to update the booking. we can retrieve the booking where Booking id=Custom field id and update the statue of booking.

    Hope this helps!

    Thanks!

    • Marked as answer by Hamzak Wednesday, August 21, 2013 1:13 PM
    Wednesday, August 21, 2013 10:24 AM
  • I created a 1:N relationship between Booking and Discharge by going to Customization->Entities->Booking->1:N Relationship.

    I hid the lookup field in Discharge form and then made a workflow that will update another hidden field in Bookings based on one of the value I select from Discharge. But the workflow is not working and is giving me the error "The required record to update was not found" which means it does not know which record to update in Booking. 

    Hence the problem of linking the records and updating the exact record remains. 

    And can you update the second method of yours? Do I create a javascript?
    Wednesday, August 21, 2013 11:33 AM
  • And maybe I don't need to update the hidden field....I can just work with when the person is discharged the related record in Bookings should get Inactive. The issue thus is how to relate the two records. 
    Wednesday, August 21, 2013 12:21 PM
  • Hi,

    As per your Scenario... I have Account (booking) and Discharge (Contact). I have created workflow on create of Discharge (Contact) that has successfully updated the Account (booking) lookup selected on Contact. Hope You have selected the Record shown in Related Entities.

    Also please make sure that If you update the Booking value from the Discharge field value then make sure both should have exact value in the option set field (Option Set Text is not important).

    Hope this helps!


    • Edited by KalimK Wednesday, August 21, 2013 12:40 PM
    Wednesday, August 21, 2013 12:39 PM
  • KalimK thank you for your help. I was missing the step where I have to select the booking from the look up in Discharge. 

    Can we do it without this extra step? 
    Wednesday, August 21, 2013 1:13 PM
  • Hi,

    You will have to set the Booking Lookup value on discharge entity, Otherwise how a workflow will recognize the record that need to be updated.

    Hope this helps!

    Thanks!

    Wednesday, August 21, 2013 4:38 PM