# Computed field : How to add / forward Proposal Ref No and Date, that will be transferred in Sales orders (complementary attributes)?

**URL:** <https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650>\
**Category:** Using my Dolibarr\
**Tags:** v16, Question, Help\
**Created:** [December 6, 2023, 5:43pm UTC](https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650 "2023-12-06T17:43:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nexuspk](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nexuspk](https://www.dolibarr.org/forum/u/nexuspk)\
**Post date:** [December 6, 2023, 5:43pm UTC](https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650/1 "2023-12-06T17:43:37Z")

</div>

Hello,

I would like to transfer / forward the proposal reference No. and Date, to two different Sale Order complementary attributes (Type: 1. String & 2. Date) to appear at Sale orders when creating sales order from Proposal.

I know it can be done with Computed field but having issue with the code to define the reference & date.  
I tried the following for ref. but it is fetching the wrong Proposal reference

`(($reloadedobj = new Propal($db)) && ($reloadedobj->fetchNoCompute($objectoffield->socid) > 0)) ? $reloadedobj->ref : 'Not found'`

Could you please give me some advices how to proceed?

Thank you.

---

<div class="post-metadata">

**Author:** ![ksar](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/ksar/32/514_2.png) [@ksar](https://www.dolibarr.org/forum/u/ksar)\
**Post date:** [December 6, 2023, 8:24pm UTC](https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650/2 "2023-12-06T20:24:15Z")

</div>

Hello,

Actualy, with your formula, you are loading the Proposal, with the

> [@nexuspk](#):
>
> socid

Means the third party ID…

First try to just put `print_r($objectoffield)` in the computed field.  
It will display all the field of the object.  
Try to see what is the name of the reference id of the proposal.  
then replace `socid` by the good attribute on your formula and it should work.

---

<div class="post-metadata">

**Author:** ![nexuspk](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nexuspk](https://www.dolibarr.org/forum/u/nexuspk)\
**Post date:** [December 6, 2023, 9:38pm UTC](https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650/3 "2023-12-06T21:38:43Z")

</div>

Hi ksar,

I ran the `print_r($objectoffield)` and found the reference id as **[ref] =\> TE/CT02/302** (showing the right proposal no as TE/CT02/302 ) then I changed thr code to

`(($reloadedobj = new Propal($db)) && ($reloadedobj->fetchNoCompute($objectoffield->ref) > 0)) ? $reloadedobj->ref : 'Not found'`

but still getting the Not found in the computed field. attaching images for your reference.

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/a/a018187ba31938d4af48c4309960ad19be6b2169.png)

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/c/cb1df952d557fd61a957f089882fdf4712e8b3f6.png)

---

<div class="post-metadata">

**Author:** ![ksar](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/ksar/32/514_2.png) [@ksar](https://www.dolibarr.org/forum/u/ksar)\
**Post date:** [December 7, 2023, 9:28am UTC](https://www.dolibarr.org/forum/t/computed-field-how-to-add-forward-proposal-ref-no-and-date-that-will-be-transferred-in-sales-orders-complementary-attributes/24650/4 "2023-12-07T09:28:37Z")

</div>

Hello,

If `ref` is part of the object, then the formula should be `$objectoffield->ref`
