Referencing employee profile

Hello,

I’m new to Scipio and I’m currently trying to change part of Scipio to make it a better fit for my project.
Under the fixed asset session, I have successfully added a blank text field named test. The effect is below
image
image
The correlated changes in codes are:

  1. Under applications/accounting/entitydef/entitymodel.xml
    added: image under FixedAsset entity. no relation is added.
  2. Under applications/accounting/widget/assets/FixedAssetForms.xml
    added: image under list asset form
    added: image under create asset form

What I’m looking to achieve next, is to show the user ID as a hyperlink towards the employee profile, or simply show the First name and Last name of the related user ID in list asset screen.
I know I will have to refer to a foreign value in another file, but I don’t know

  1. How do I refer it? is it “${}” or is it something else?
  2. which form should I refer to?

Thank you so much for helping.

First get the FixedAsset, in ftl it would be something like this:
<#assign fixedAsset = delegator.findOne("FixedAsset", {"fixedAssetId" : fixedAssetId }, false|true)>
then render the a tag like this
<a href="${makePageUrl("....?param=${fixedAsset.test")}">.....</a>

HTH

Thank you for replying!
The reply shines a dim light to me but I’m having a hard time understanding it. I’m looking for showing person’s name in fixedassetscreen. But it looks like you’ve suggested to create a reference .ftl file for other files to access fixedAsset.test ?

The ‘test’ part is to show how less I understand about Scipio, it has nothing to do with my question. Sorry if this brings misunderstanding.

Thank you.

Hey, and welcome.

Okay, if i understand you correctly, you are trying to do all this inside a form widget of sorts? (you did not specify which one and there are several in FixedAssetForms.xml, so it is a bit difficult to understand)

That being said, you can use row-actions to lookup a name like so:

    <row-actions>
            <entity-one entity-name="PartyAndPerson" value-field="party"/>
        </row-actions>

You will need to have the partyId in the current row context for this to work, however, otherwise you may need an additional lookup before this, so you get the right info. Afterwards you can use a snippet like the following to map to a particular screen:

<field name="myLink" title=" " widget-style="">
    <hyperlink target="editParty" description="my text" also-hidden="false">
        <parameter param-name="partyId"/>
    </hyperlink>
</field>

Just an example (you will need to update this accordingly)

I should mention, @minifreak was refering to a scenario in which you are inside a freemarker (.ftl) file. Probably explains the confusion here…

Hi Madppiper,

Thanks for replying!
First let me clarify the FixedAssetForms.xml.
As I’ve explained in the first discussion, the path is: applications/accounting/widget/assets/FixedAssetForms.xml.
I’m trying to change the ListAsset part of the .xml file so it can show different things as I posted earlier (the test blank text field is an example I did)

From your reply it looks like I can lookup the person’s name using row-actions. But i’m kind of confused how it can be used for display. I’m afraid maybe I haven’t described this clear enough so please forgive me for once again trying.

image

This is What I currently have. You can see that compare to default scipio I have 2 more columns, the test field and user field.
Under user column, there’s the user id that I typed in (from create new asset form I can search for people who owns it, but I can only input his id). I’ve made it a hyperlink. Currently this hyperlink doesn’t work properly.

I’d like to either.

  1. click the user id and jump to employee profile (who owns this asset)
    or
  2. make this column show the name of the employee, not a hyperlink.

Thank you again for your kind reply.

Hey,

yeah, then i understood you, I think. As for the file you linked: the file contains multiple form widgets, not just one. They are used by several screens, so it becomes really difficult to find where you are actually trying to change something. The screen you provided helps though. I think you are editing the form starting with

<form name="ListFixedAssets" type="list" list-name="listIt" paginate-target="ListFixedAssets"

(We usually reference these as component://accounting/widget/assets/FixedAssetForms.xml#ListFixedAssets as that is the location you will probably find in the referencing files).

But i digress. It is great that you managed to add the two fields. The second example i provided is really what you are looking for. You have to use your userId to lookup your person data (in reality you have to first lookup a party with the userId and a person from there), but you can either use a service to do this, or simply directly lookup the value in a table. There is a handy little table by the name of “PartyAndUserLoginAndPerson” that you can use to do so. You will have to do this as a row-action:

 <row-actions>
            <entity-one entity-name="PartyAndUserLoginAndPerson" value-field="person">
              <field-map field-name="userLoginId" value="${userLoginId}" />
            </entity-one>
        </row-actions>

And then where you display the field, you will have to change the code to:

<field name="User" title="My Title" widget-style="${styles.link_nav_info_id}">
            <hyperlink target="/partymgr/control/viewprofile" target-type="inter-app" description="${person.groupName} ${person.firstName} ${person.lastName}">
                <parameter param-name="partyId" from-field="person.partyId"/>
            </hyperlink>
    </field>

P.S.: I also recommend to check out the documentation here: https://www.scipioerp.com/community/developer/views-requests/screen-widgets-decorators/

Sorry to bother you again madppiper,

I’ve input the code as you stated, yet the link did not appear as expected. It does show the column and title, but underneath it is empty. I’m guessing either the field you’re trying to query is empty or the link address doesn’t work?

image

If I read this code correctly, you’ve linked “person’s userLoginId” to field-name userLoginId.
Then within the hyperlink you tried to target /partymgr/control/viewprofile+person’s id, and show it as person’s name.

Thank you again for replying.

Yeah, i did not try the code, just gave an example of how to do it. Are there any errors thrown in the console?

Also, you will want to remove ${person.groupName} from the link description. That field doesn’t exist on entity (i did not check all the values).

I’ve changed the ${person.groupName} ${person.firstName} ${person.lastName} to ${partyId}
It now shows the ID correctly, but the link leads me to admin’s profile instead of JohnJin’s. I’m guessing the “person” must be set to admin when creating this link. As for how this happens, it either picked the first ‘person’ or it picked ‘the person that’s currently logged in’. rather than ‘the person who’s associated with this id’

I’ll try a couple parameters here and there, see what happens.

My best guess is that userLoginId in context refers to your current login, not the row value.

You are doing a lookup:

<field-map field-name="userLoginId" value="${userLoginId}" />

Change that second value to your field you mean to lookup.

image
I’ve changed the code to this. however the person.firstName still shows nothing. (although there is actual value in the profile set)
I’ve corrected the parameter so at least now the hyperlink leads to the correct profile.

If you can provide a place where I can lookup all the code syntax and explanation, it will be really helpful.

Thank you again.

Hello again,

I’ve changed the code to below:
image
The result does not achieve what I want.
image

Note that If I change the entity-name=“Person” to entity-name=“PartyAndUserLoginAndPerson”, it will return error, also as shown in the result pic, the parent column shows perfectly just as what I want it to be. (a value in the entity + hyperlink). The code of that column is below:
image

Through the talk I do understand that a ‘lookup’ is needed (although I don’t know why). But I’m not sure of the syntax of the code you provided. Thus, it would be hard for me to start to debug it.

If any suggestions, thank you very much.

Hi,

a “lookup” is needed because in the table you are essentially rendering, you only have the FixedAsset entity in context. Or in other words: you are trying to loop over the FixedAsset entity and that one does not contain any information about the person itself. There is a reference to it and a few “view-entities” (dynamic entities), which have the data, but if you want to make use of them, you will have to use the data you have to lookup a value inside of them. Afterwards you can use them in your table again. The “row-action” allows you to use the information available inside the current row for shannigans like this.

You are right, that you can also just use “Person” for this. I was unaware that “partyId” is a field inside the FIxedAsset column, so if set, you can use it to retrieve the other info. Be aware though, that it is not a mandatory field on the FixedAsset data, so it could just not be set.

You can use the following as a starting point for whatever you want to do, i implemented a few examples in there for you:

<form name="ListFixedAssets" type="list" list-name="listIt" paginate-target="ListFixedAssets"
          odd-row-style="alternate-row" header-row-style="header-row-2"> <!-- orig: default-table-style=-style="basic-table hover-bar" -->
        <actions>
            <service service-name="performFind" result-map="result" result-map-list="listIt">
                <field-map field-name="inputFields" from-field="parameters"/>
                <field-map field-name="entityName" value="FixedAsset"/>
                <field-map field-name="orderBy" from-field="parameters.sortField"/>
                <field-map field-name="viewIndex" from-field="viewIndex"/>
                <field-map field-name="viewSize" from-field="viewSize"/>
            </service>
        </actions>
        <row-actions>
            <service service-name="calculateFixedAssetDepreciation" result-map="assetDepreciationResultMap">
                <field-map field-name="fixedAssetId" from-field="fixedAssetId"/>
            </service>
            <if>
                <condition><not><if-empty field="partyId"/></not></condition>
                <then>
                    <entity-one entity-name="Person" auto-field-map="true" value-field="person" />
                </then>
            </if>
        </row-actions>
        <field name="fixedAssetId" title="${uiLabelMap.CommonId}" widget-style="${styles.link_nav_info_id}" sort-field="true">
            <hyperlink also-hidden="false" description="${fixedAssetId}" target="EditFixedAsset">
                <parameter param-name="fixedAssetId"/>
            </hyperlink>
        </field>
        <field name="fixedAssetName" title="${uiLabelMap.CommonName}" sort-field="true">
            <display/>
        </field>
        <field name="User" title="User" widget-style="${styles.link_nav_info_id}">
            <hyperlink target="/partymgr/control/viewprofile" target-type="inter-app" description="${person.firstName} ${person.lastName} (${partyId})">
                <parameter param-name="partyId" from-field="person.partyId"/>
            </hyperlink>
        </field>
        <field name="fixedAssetTypeId" title="${uiLabelMap.CommonType}" sort-field="true"><display-entity entity-name="FixedAssetType"/></field>
        <field name="parentFixedAssetId" title="${uiLabelMap.CommonParent}" sort-field="true">
            <display-entity entity-name="FixedAsset" key-field-name="fixedAssetId" description="${fixedAssetName}">
                <sub-hyperlink target="EditFixedAsset" description="${parentFixedAssetId}">
                    <parameter param-name="fixedAssetId" from-field="parentFixedAssetId"/>
                </sub-hyperlink>
            </display-entity>
        </field>
        <field name="dateAcquired" sort-field="true"><display type="date"/></field>
        <field name="expectedEndOfLife" sort-field="true"><display type="date"/></field>
        <field name="purchaseCost" widget-area-style="amount" title-area-style="align-right" sort-field="true"><display type="currency" currency="${purchaseCostUomId}"/></field>
        <field name="salvageValue" widget-area-style="amount" title-area-style="align-right" sort-field="true"><display type="currency" currency="${purchaseCostUomId}"/></field>
        <field name="depreciation" widget-area-style="amount" title-area-style="align-right" sort-field="true"><display type="currency" currency="${purchaseCostUomId}"/></field>
        <field name="plannedPastDepreciationTotal" widget-area-style="amount" title-area-style="align-right"><display description="${assetDepreciationResultMap.plannedPastDepreciationTotal}"/></field>
        <on-event-update-area event-type="paginate" area-id="search-results" area-target="FixedAssetSearchResults"/>
    </form>

It works!!

Thank you so much :slight_smile:

1 Like