This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - how to retrieve source item information from related item before relationship/source item is saved using serve method

Santhosh - Friday, March 4, 2011 7:26 AM:

Hi Community,

Is it possible to retrieve source item information from a related item using server method before the related item is saved.

Please advice.

Santhosh



vishal_trivedi - Thursday, March 17, 2011 9:19 AM:

Hi Santosh,

Can you please explain it by UI??

At what particular place you want  the data??

- Vishal



SamsAn - Thursday, March 17, 2011 5:46 PM:

Hi.

There are two cases.
1. Related Item update. OnBeforeUpdate server-side event can be used for this Item Type. The query like below can help

<Item type="[Relationship Type Name]" action="get" select="source_id(*)"><related_id>this.getID()</related_id></Item>.

2. Related Item add. OnBeforeAdd/Update server event for [Relationship Type Name] ItemType can be used. Put this.getProperty("source_id") into the session. Then this value can be used in OnBeforeAdd server event for the Related Item.

SamsAn.



vishal_trivedi - Friday, March 18, 2011 12:45 AM:

Hi Santhosh,

SamsAn is right...

Vishal



Santhosh - Wednesday, March 30, 2011 2:23 AM:

Hi SamsAn/Vishal,

I'm trying to retrieve the source item information when I'm adding Related Item.

Could you please explain what does this mean

"Put this.getProperty("source_id") into the session. Then this value can be used in OnBeforeAdd server event for the Related Item."

Does this mean there should be a property in related Item to hold source id. I'm little confused, how I can access property from a relationship type name before relation is added.

Could you please provide a small example.

Santhosh

 



vishal_trivedi - Wednesday, March 30, 2011 3:47 AM:

Normal 0 false false false MicrosoftInternetExplorer4

 

Hi Santhosh,

I am giving you a very simple example.

 

1)      Suppose you are working on Document and File.

2)      Your file is assigned in many documents.

3)      So, there are 2 documents i.e. Doc1 and Doc2 and a file FL1.

4)      Now Doc1 and Doc2 are your sources for relationship between Doc1 & FL1 and Doc2 and FL1.

5)      Apply Sql query for that.

 

Now you are in window of File i.e. FL1. which is related_id for us.

In every relationship, 2 ids will be there source_id and related_id.

Now, id of FL1 is related_id and ids of Doc1 and Doc2 are source_id.

Innovator inn = this.getInnovator();

Item result = inn.applySQL(“select source_id from innovator.[Document_File] where related_id = ‘<id of  FL1>’”);

//result will contain all the documents in our case Doc1 and Doc2.
 
 If you still have any doubt then post it i will reply..
Cheers,
Vishal


vishal_trivedi - Wednesday, March 30, 2011 4:53 AM:

Hi Santhosh,

Is your problem solved or not??

Vishal



Santhosh - Wednesday, March 30, 2011 4:55 AM:

Hi Vishal,

The query which you have given, will it work untill the relationship type(source) is saved?

If I understood correctly I have to use this query in "OnBeforeAdd/Update" or "OnAfterAdd/update" server events of Relationship Type name.

Please correct me if I'm wrong.

Santhosh



vishal_trivedi - Wednesday, March 30, 2011 5:23 AM:

Santosh,

Coming back to your main Question.

Is it possible to retrieve source item information from a related item using server method before the related item is saved.


-- For above question give me your related Item Type and Source Item Type.

Also enjoy match of India V/s Pak.

Vishal



Santhosh - Thursday, March 31, 2011 1:12 AM:

Hi Vishal,

My source and related Item type are same. It is a Circular relation.

Thanks Vishal I njoyed the match, I hope you also njoyed it.

Santhosh



vishal_trivedi - Thursday, March 31, 2011 6:47 AM:

Normal 0 false false false MicrosoftInternetExplorer4

Hi Santhosh,
 
Here I am considering that you are working with Part.
 
1)      There are Part A and Part B in your Aras.
2)      Part B is related to Part A.
3)      So, in Part to Part relationship if you open Part A, Part B can be seen under Part A.
4)      Now, you are going to open Part B and you are making some changes in it and at the time of committing these changes you want the id of Part A.
 
 
Am I right??
 
Vishal
 


Santhosh - Friday, April 1, 2011 1:22 AM:

Hi Vishal,

If we consider me working on Part then below given is what I'm trying to achieve.

1) I have Part A.

2) I'm creating Part B as related Item to Part A.

3) Now while saving Part B, I wanted to get the ID of Part A.(Part B is a new Item, still not saved)

Please let me know if this not clear.

Thanks

Santhosh