Category:Relatedentity Action

From JRapid

Jump to: navigation, search

Relatedentity actions associates the action to an entity. Associating an action to a forms implies that the code for that action will run in the Java service of that entity.

Usage:

<action type="relatedentity" entity=ENTITY name=NAME  label="Discard" location=LOCATION 
        Optionals:{defaultset=DEFAULTSET, defaultsetparams=PARAMS}
/>
  • entity: the name of the associated entity.
  • defaultset: the defaultset which will load the associated entity property values. This defaultset must declare a first parameter with entity=SOURCE_ENTITY_NAME because this one is always sent as the first argument.
  • defaultsetparams: valid only when using location=form, location=local or location=main.

Example:

  • The "discardOpportunity" action.

The "discardOpportunity" action changes the "status" property of a Opportunity of a Company to a "discard status". We want the user to click on a action-button and select the new status of the opportunity and write some comments. This type of actions are called "related-entity" actions. This kind of actions associates the action to a transient entity which initializes the action values, in this example the new status and the comments.

The "Discard" transient entity will be associated to the "discardOpportunity" and a defaultset will be specified to initialize the "opportunity" property.

Discard entity
<entity label="Discard" name="Discard" transient="transient">
        <property entity="Opportunity" fixed="fixed" label="Opportunity" name="opportunity"/>
        <property display="primary" displayproperties="state" entity="OpportunityState" 
        label="Switch opportunity to:" name="state" subset="forDiscard" whennotinsubset="donotshow"/>
        <property display="secondary" label="Reason" name="reason" type="enum">
            <enum value="C">Competition</enum>
            <enum value="DQ">Does not qualifies</enum>
            <enum value="P">Price</enum>
            <enum value="NI">No interest</enum>
        </property>
        <property label="Comments" name="comments" type="text"/>
</entity>

We want the "opportunity" property of the action to be the same opportunity from where the action was triggered so we create a defaulset which recieves a "opportunityParam" param

Defaultset

which is added to the Discard entity.

<entity label="Discard" name="Discard" transient="transient">
        <defaultset name="defaultForOpportunity">
            <param entity="Opportunity" name="opportunityParam"/>
            <default name="opportunity" value="opportunityParam"/>
        </defaultset>
        <property entity="Opportunity" fixed="fixed" label="Opportunity" name="opportunity"/>
        <property display="primary" displayproperties="state" entity="OpportunityState" 
        label="Switch opportunity to:" name="state" subset="forDiscard" whennotinsubset="donotshow"/>
        <property display="secondary" label="Reason" name="reason" type="enum">
            <enum value="C">Competition</enum>
            <enum value="DQ">Does not qualifies</enum>
            <enum value="P">Price</enum>
            <enum value="NI">No interest</enum>
        </property>
        <property label="Comments" name="comments" type="text"/>
</entity>

The "discardOpportunity" action specifies a "defaultForOpportunity" defaultset.

Discard Action
<entity label="Opportunity" menu="Opportunities" name="Opportunity">
   ...
   <action defaultset="defaultForOpportunity" entity="Discard" label="Discard" location="button"
   name="discardOpportunity" type="relatedentity"/>
   ...
</entity>

When the "discardOpportunity" action is triggered from the Opportunity listing, the opportunity property of the action is loaded by the defaultset.

Defaulset loads "opportunity" property



  • Relatedentity action:

In our next example we have a listing of employees and we are going to implement the "review employee" use case by connecting the AttendantReview form with the listing. In order to accomplish that we are going to use the "relatedentity" type action setting a defaultset that will automatically link the employee entity with the Review form by setting the employee field in the AttendantReview entity.

 <entity name="AttendantReview" label="Attendant Review" >
    <defaultset name="forEmployee">
       <param name="employee" entity="Employee"/>
       <default name="employee" value="employee"/>
    </defaultset>
    <property name="reviewDate" label="Date" type="date" display="primary"/>
    <property name="employee" label="Employee" entity="Employee" display="primary"/>
    <property name="finalScore" label="Score" display="secondary" />
 </entity>
 <entity name="Employee" label="Employee">
    <property name="name" label="Name" display="primary" unique="unique"/>
    <action label="Evaluate" type="relatedentity" entity="AttendantReview" 
         defaultset="forEmployee" location="button"/>
 </entity>

Besides the ids chosen, extra parameters can be added to the defaultset, for that you use the defaultsetparams attributes separating them by a semi colon.

Subcategories

This category has only the following subcategory.

r

Pages in category "Relatedentity Action"

The following 2 pages are in this category, out of 2 total.

D