locked
Avoiding system requirements regarding "incident" entity RRS feed

  • Question

  • Hi,

    I got a task which requires adding new validating functionality to the "incident" system entity. I have to modify it using jscript so it should be possible to create and save new element of incident entity which may be assigned not only to account but also only to the lead (with new custom reference defined to the lead entity). Of course customerid is a system required field, so I used appropriate command in jscript to take the requirement off which seems to work, bu only when I load window. Here is my jscript code sample:

    function unlock()
    {
    Xrm.Page.getAttribute("customerid").setRequiredLevel('none');
    }
    
    
    function validate()
    {
    var val1 = Xrm.Page.data.entity.attributes.get('customerid');
    var val2 = Xrm.Page.data.entity.attributes.get('new_leadid');
    
    if (  val2.getValue()==null && val1.getValue()==null )
    
    {
    alert("You must fill ‘Customer’ or ‘Lead’ field")
    event.returnValue = false;
    }
    
    }

    Now, when I open new entity window I can see that customerid field is not system required anymore (red star dissappear). If I try to save the incident entity with customerid and new_leadid flieds blank, the alert appear. I can save new entity with assigning to it only account. But when I try to save it only with the lead assigned to it, system throw the message  detailed below:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: You should specify a parent contact or account.Detail:
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147204080</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>You should specify a parent contact or account.</Message>
      <Timestamp>2012-05-09T14:48:13.4244116Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    It seems that system still requires customerid to be field, even if I can manage to set its required level to none. Is there a way to do so?

    Regards.




    Wednesday, May 9, 2012 2:50 PM

Answers

  • You are correct - you won't be able to use the out of the box incident entity without populating the customer. 

    Jason Lattimer

    • Marked as answer by Kubas_86 Wednesday, May 9, 2012 3:21 PM
    Wednesday, May 9, 2012 3:20 PM
    Moderator

All replies

  • I don't think using JavaScript to change the requirement level is going to work. The customer on an incident is required at the system level and can't be changed. As such, any API calls are going to need it to be populated with an account or contact id. 

    Jason Lattimer

    Wednesday, May 9, 2012 2:57 PM
    Moderator
  • Thank you for your interest and quick response, JLattimer :)

    Does it mean that it is impossible to do it in the way I was asked to and the only solution would be creating new custom incident entity?

    • Edited by Kubas_86 Wednesday, May 9, 2012 3:08 PM
    Wednesday, May 9, 2012 3:06 PM
  • You are correct - you won't be able to use the out of the box incident entity without populating the customer. 

    Jason Lattimer

    • Marked as answer by Kubas_86 Wednesday, May 9, 2012 3:21 PM
    Wednesday, May 9, 2012 3:20 PM
    Moderator