How to assign contact Role by code? - axapta

I have to assign a Role for a Customer?
I am creating a Customer, after that, for creating a role,
I have already the contact in GlobalAddressBook , I want to add a ROLE for this contact, I don't wanto to create a new record in DirPartyTable.
I use this code:
DirPartyRelationship::createRecordRelations("Vendor" , CompanyInfo::find().RecId , this.findDirPartyRecid().RecId , curext());
I created a record on Table DirPartyRelationship , but on GlobalAddress form (in HomePage) I can't find the new role for my Vendor.
I sow some classes : DirParty , and nother, but I don't know how to use? If I have to use.
Is there a class for creating a role by code? I don't know how I to do this.
Thanks all,
Enjoy!
I appreciate your help!!

I found one of the possible solution.
If I already have a contact (example Vendor o Customer)
I have to take its value in field Party and use this value forcing in the same field in the Cust/Vend Table.
Exaple: if I have a Customer, go on VendTable, I take the value in Party field.
When I create in CustTable my new Customer I force the value taken into in VendTablein field CustTable.Party.
Automatically when I create a customer create a new role, with this system associate a Role.(for my Company).
If you have more information updated my answer.
Thanks all!
References:
https://community.dynamics.com/ax/f/33/t/170776 ;
https://community.dynamics.com/ax/f/33/t/174210?pi51736=1#responses ;
https://msdn.microsoft.com/en-us/library/vendtable.aspx .

Related

ASP.NET MVC : how to display int rating value in star in a table?

I have a database like:
I want to display the rating of the question.
The column Rating is int contain the rating point from each user.
How can I display this int value as a rating star?
Please help me - how do I start my controller and view?
You can achieve this using JQuery plugin , so you pass the value you want to the view as usual , the same way you pass all the model data , after that , The Jquery plugin is gonna take care of displaying that value in form of stars . all you have to do is including the Jquery plugin in your scripts and follow the documentation on how to use it. For that purpose , I advise you to use the RateYo plugin , you find here all the required info about it and how to use it . For mopre options , you may refer to this link to choose a different plugin
You need to add a new controller
Add a new View
Add a model to hold the value "Rating"
look into how to get your connection string and connect to your database
Initialise the model in your new controller
populate the model with the value from the database
return the model to the view
go step by step and research each bit

Drupal Group module, add a user to a group with a particular role programmatically

This question is related to Drupal 8 Group module, https://www.drupal.org/project/group
I am stuck and need help with how to programmatically add a user to a group with a particular role. I am trying to assign a user to a group and role via a feed import but unable to figure out how.
To elaborate, let's say we have two groups DEV and QA. DEV is of group type A and QA is of group type B. Both groups type A & B have roles X, Y and Z (group roles). Now, I have a user $account and I want it to get added to say group QA with role Y. Can someone help and state a way I can achieve this programmatically? Code examples/snippets will be extra helpful.
Some OLD code here that may help. Had to dig it out of git, deleted a couple of years ago as no longer needed by the project. May be deprecated!
You are loading up the group and using the $group->addMember() function. I have just added the member but you can add a second param that is an associative array that can indicate roles to add to.
$new_user = \Drupal\user\Entity\User::load($some_user_id);
// Get the group entity.
$gid = $form_state->getValue('gid');
$group = \Drupal::entityTypeManager()
->getStorage('group')
->load($gid);
// Add user as a member of the group.
$group->addMember($new_user);
// Set the owner of the group to be the user.
$group->set('uid', $new_user_id);
// Save changes to group. Anything below here should only be changes to
// Group Content.
$group->save();
$tags = $group->getCacheTagsToInvalidate();
Cache::invalidateTags($tags);

Create a record on DirPartyTable from code?

I have to create a new record on DirPartyTable .
I used this code:
DirPartyTable _myDirPartyTable;
myPartyNumber = DirPartyTable::getNewPartyNumber((webSession() == null));
myDirPartyTable = DirPartyTable::createNew(myPartyType , myName, myPartyNumber);
// or without partynumber
myDirPartyTable = DirPartyTable::createNew(myPartyType , myName);
But in both cases the standard method generate two Sequence ParyNumber.
In Debu mode I saw the system get two times the PartyNumber .
How can I create a record without creating holes in the sequence numeric?
I tried to use this another code:
select forupdate myDirPartyTable;
myDirPartyTable.name = ....;
//etc
myDirPartyTable.insert();
But does not create the record.
Thanks,
enjoy!
DirPartytable is the basis table of address book framework and is the top level of table inheritance hierarchy see references in Implementing the Global Address Book Framework (White paper)
You shouldn't try to directly create a party but create from your entity which implement the DirParty framework. When you create a vendor, you don't create a DirParty (with herited tables) and then create a VendTable and link them all together. Creating a vendor will do it directly.
Then, if you still encounter two times Party number calls, log a case at Microsoft support.
ulisses: I solved problem, I have to create before the PartyType (Organization or Person etc...)and after update my created DirPartyTable.
Just try the AxDirPartyTable Class like:
AxDirPartyTable axDirPartyTable;
axDirPartyTable = AxDirPartyTable::construct();
axDirPartyTable.parmName(myName);
axDirPartyTable.parmPartyNumber(myPartyNumber);
axDirPartyTable.save();
Examples could be found here: How to create a record in Global address book throgh code.

How to add additional field to drupal organic group 'User and Group' relation?

Im using Drupal Organic group module and I want to create a group and need to assign users (filter by perticular role) to that group. I have done that part easily but the problem is that, I need to add aditional note on per each group user relation.
Lets say there is a group called "School Prefects" and need to add users to that group whos role is student. In here I need to put a small description for each relation.
Please help me to figure this out.
Thanks in advance.
I will probably deal with the same problem soon.
I think a possible workaround is to use the relation module and
the rules module. You could set up a rule to create a relation
each time a user is assigned to a group, or something like that.
Relations made by the relation module are fieldable. But it would be
maybe better to add a field to the og user-group relation directly.
Update: now that I tackled the issue, I have a different solution. We don't need to add new relations, the og_membership shipped standard with og is all that we need. This is how I did it.
I created a new membership type from admin/config/group/group-membership. It's a fildable entity so I added the required fields: in your case it will be "description".
Then I changed the used membership type per user, I did it in admin/config/people/accounts/fields/og_user_node (I needed to change the field "group membership" in user account).
So, now when you (or a group administrator) go to "manage group page" (clicking the group tab in group node), where you can add new people or manage members, either way you can edit your custom field "description" on each membership users-group.
Besides, you can clone the "og members" view adding the field "description", so in people panel in the group homepage we see name + description.
I my use-case I had to see (per group member): name, role, start date, end date. E.g. John Doe, president, from 1997 to 2003.

filtering datagrids

In a simple scenario there is a webpage with a datagrid containing 2 columns; first name and country. There's a filter set on the grid to filter out all Australians. There's a form on the same page to add new records and a user decides to add someone from Australia. This record does not meet the filter criteria so would not normally display. However, this might be confusing from the users perspective as they might not have confidence that the person has been successfully added or have forgotten that the filter will mean the new entry is not displayed.
What is the best way to handle this from a usability perspective?:
display the new entry but leave the list in a state inconsistent
with the filter criteria?
filter out the new entry but risk confusing the user?
provide feedback to the user that the record was successfully
added but may be filtered out of the list?
?
Three tools I use, Mingle, Jira, and Quicken, use this implementation very effectively; a slight modification to your number 3:
Provide feedback to the user that the record was successfully added, but won't be shown, and provide a link to the record using its record identifier (record number + title).

Resources