I understand that these initFrom(TableName) methods are to initialize fields in a table for related tables. Where are they called from? I want to follow this pattern but where do I call this method?
Every documentation on this pattern just tells me what I said above and no examples of using them. I see examples of them being created.
Maxim Lazarev made a point about using the cross-reference tool. I ignorantly did not realize that you had to update it on the table and then you can see what calls on that method. That lead me to examples of it being used in overridden table methods like modifiedField. I'm starting to play around but it looks like I can now use these initFrom methods to fill in specific data I need in forms whether it's directly in the table or in the actual form itself.
The initFrom methods are to initialize the record based on another record. They are not called automatically, you can use them yourself
though.
For example PurchTable.InitFromVendTable() sets all the relevant values from the vendTable to the (new) purchtable record. So if you want to create a Purchase Order and you have the vendor, you can use this method to set the correct values.
Related
Please see the below scenario
I have form A,B and C.
I search B using fields from A to get a result list.
result list contains one column with IDs of C form.
Now I want get a field from A, set it in C for only those IDs returned by B.
I know if confusing but I have made it as simple as possible. Please help me accomplish the above operation in BMC Remedy Developer Studio (ARSYS)
Your question isn't very clear, but I think that I understand your need. I think the primary issue is that you are thinking in terms of the GUI (results lists, active links, etc.). Instead you need to think of server-side workflow, filters and escalations. The other key is to use hidden fields to hold your IDs, data to push, flags.
I'm not sure what your trigger will be to make this all happen, so that will change the workflow. You could start with an entry A being created/modified. This will trigger a filter that does a set fields action querying B to pull back the IDs and save them into a hidden field. You then have another filter on A that checks for a value in the hidden ID field. It does a push fields action to save the data from A into the correct entry of C.
That's the basic idea which could be improved with a better understanding of the fields and flow.
What is the code to manually switch a form to a specific record? I was trying to use relations but I can't make a relation to a calculated table, which is where this is coming from, so I have to hardcode which data is populated.
I'm looking for something like
onLoad()
(read the ID from page properties, which I use for globals)
widget.item.select(id);
I think you would want to use:
widget.datasource.selectKey(id);
This works on the assumption that your record is currently loaded in your client however. If your record is not loaded then this will not work.
I have done research about setValue() and updateChildren(). I have tested both of them to add and update data from firebase database. From what I have learnt that both of them did the same exact thing and did some research about them.
From what I have learnt. The setValue() is used with a class object while updateChildren() is used with a Map or HashMap. Correct me if I'm wrong.
My question is as stated above, what is the difference between setValue() and updateChildren()?
'setValue' method is totally replacing the document (specified reference) with new data.
'updateChildren' method is just updating particular fields or add such fields if they did not exist before.
You often can get the same result using those methods, but actually they are different.
Using an example where your user has fields: Name, Birthday, Favourite Colour.
Set value requires you to set all the fields under the same parent node otherwise they are overwritten with no values and deleted.
However, using updateChildValue, you can specify which field you would like to update without altering other fields. And, if the field doesn't already exist, it will create a new field. This is especially useful if you just want to add a new field under the user like hair colour.
We created special form to creating purchase prices for vendors.
New form has almost the same fields as original (so we used PriceDiscTable), but the record/datasoruce was set as temporary table. After user filled mandatory fields will click button, (extra logic behind) and record will inster to database (real priceDiscTable).
The idea was to grand access to trade prices for users that not necessarily has access to purchase prices. In theory everything was ok, but when user with no access to PriceDiscTable open new form, error was shown "Not enougt right to use table 'Price agreements'".
We try set the AllowCheck to false in formDatasource but this only allow us to open the form, but user still cannot add or modify records.
Is there any way to force system to allow user to write data in the temporary table?
Disabling security key or grand access to real table is not an option.
Duplicate table and create with same fields is nuisance (if we use same table we can use data() method to assign fields)
I think that creating a new temporary table with [almost] the same fields would be the best solution.
If the only reason you oppose to this approach is that you wouldn't be able to use data() to copy data from one table to another you can use buf2BufByName() as described here: http://mybhat.blogspot.co.uk/2012/07/dynamics-ax-buf2buf-and-buf2bufbyname.html
You can use RunAs to impersonate another user...perhaps a system user. I don't entirely follow what you are trying to do, but it sounds like this solution would work for you if you know exactly what your custom code is doing and is capable of.
See Classes\AifOutboundProcessingService\runAsWrapper to see an example.
You will not be able to display the PriceDiscTable without giving the user at least "view" access or editing Classes\FormRun to somehow bypass the security key, which is kernel level so it's also not possible.
I agree with 10p where you should create a temp table and then create a custom method handler combined with buf2bufbyname() or buf2buf().
Another option you can screw around with, if you REALLY want to use .data() is using a Common as the datasource. You could add the fields you want on the grid with the common, then you can pass a common back/forth. This has a good amount of form setup to get this working, but it could produce what you want eventually I think.
static void Job8(Args _args)
{
Common common;
salesTable salesTable;
;
common = new DictTable(366).makeRecord();
select firstonly common where common.RecId == 5637145357;
salesTable.data(common);
info(strfmt("%1 - %2", salesTable.SalesId, salesTable.SalesName));
}
Just dipping my toes into Linq2sql project after years of rolling my own SQL Server DB access routines.
Before I spend too much time figuring out how to make linq2sql behave like my custom code used to, I want to check to make sure that it isn't already "built" in behavior that I can just use by setting up the relationships right in the designer...
Very simple example:
I have two tables: Person and Notes, with a 1 to many relationship (1 Person, many notes), linked by Person.ID->Note.PersonID.
I have a stored procedure (all data access is done via SP's and I plan on continuing that) which makes the Link2SQL a bit more work for me.
sp_PersonGet(#ID int) which returns the person record and sp_PersonNotesGet(#PersonID) which returns a set of related notes for this person.
So far so good, I have an object:
Dim myPerson As Person = db.PersonGet(pnID).Single
and I can access my fields: myPerson.Name, myPerson.Phone etc.
and I can also do a
Dim myNotes As Notes = db.PersonNotesGet(pnID)
to get a set of notes and I can iterate thru this list like:
For Each N As Note In myNotes
( do something)
Next
This all works fine...BUT....What I would prefer is that if I call:
myPerson = db.PersonGet(pnID)
that I also end up with a myPerson.Notes collection that I can iterate thru.
For Each N As Note In myPerson.Notes
( do something)
Next
Basically, Linq2SQl would need to call 2 stored procedures each time a Person record is created...
Is this doable "out of the box", or is this something I need to code around for myself?
This is normally what we would call child collections and they can be eager loaded or lazy loaded. Read these:
http://davidhayden.com/blog/dave/archive/2009/01/08/QuickExamplesLINQToSQLPerformanceTuningPerformanceProfilingORMapper.aspx
http://www.thinqlinq.com/default/Fetching-child-records-using-Stored-Procedures-with-LINQ-to-SQL.aspx
It uses partial classes. You can add your own "Notes" property to your Person class and initialize it in it's GETter function. This would be better than populating the notes every time you load a person record.
I believe that you can do this more or less out of the box, although I haven't tried it -- I don't use stored procedures with LINQ. What you would need to do is change the Insert/Delete/Update methods from using the runtime to use your stored procedures. Then you'd create an Association between your two entity tables which would create an EntitySet of Notes on the Person class and a EntityRef of Person on the Notes class. You can set this up to load automatically or using lazy loading.
The only tricky bit, as far as I can see, is the change from using the runtime generated methods to using your stored procedures. I believe that you have to add them into the data context as methods (by dropping it on your table from the server explorer in the designer) before it is available to use instead.