LOV not displaying drop down values after fetching values via ViewCriteria - oracle-adf

I have created a LOV which is dependent on OrganizationId and ManagerId . It should display EmployeeName.
Flow is : User select Organization then Manager(It is also an LOV) and then he can see EmployeeName.
public void applyReleaseRuleValues(){
ViewObject projectCostingTaskName =this.getProjCostingTaskVA().getViewObject();
try{
projectCostingTaskName.setNamedWhereClauseParam("bindInvOrgId",releaseOrganizationId);
projectCostingTaskName.setNamedWhereClauseParam("bindProjectId",releaseManagerId);
projectCostingTaskName.setNamedWhereClauseParam("bindTaskId",releaseEmployeeId);
}catch (oracle.jbo.NoDefException e) {
;
}
projectCostingTaskName.executeQuery();
Row pjcTask=projectCostingTaskName.first();
String setPjcTaskId=(String)pjcTask.getAttribute("EmployeeName");
setAttributeInternal(EMPLOYEENAME,setPjcTaskId );
I don't think it's an UIProject issue as Manager & Employee Name is getting displayed.In Manager LOV is visible but not for Employee.
Any suggestions?

I think you are going about trying to achieve this in the harder way. There is a much easier way to achieve Cascaded List Of Values, via simple View Object query and drag and drop on the form from the controller. If this all you want, in that case check this out:
https://waslleysouza.com.br/en/2014/10/defining-cascading-list-values-adf/
or
http://jjzheng.blogspot.com/2010/06/implement-cascading-lists-of-values-in.html
or
this video: https://www.youtube.com/watch?v=nXwL2_RP7AQ
If you need something more complex, please add it to the question

Related

How to apply a condition to a specific table in every request on Entity Framework?

I have a many-to-many structure mapped to entity framework. This is a sample of what it looks like:
User UserTag Tag
------- -------- -------
IdUser(PK) IdUserTag(PK) IdTag(PK)
Name IdUser(FK) TagName
Desc IdTag(FK) Active
Now, I needed to exclude from any request of any method the viewing of Tags that were Active=false.
First, I tried doing it manually in every method, like:
public User GetById(int id)
{
var item = UserRepository.GetById(id); //This is just a repository that calls the EF context
//EF automatically maps it to the *UserTags* property
foreach(var tag in item.UserTags)
{
if(tag.Tag.Active == false)
item.UserTags.Remove(tag);
}
}
But it throws the following exception:
The relationship could not be changed because one or more of the foreign-key properties is non-nullable
So, I wanted to know if there's a way to conditionaly filter every request made to a specific table, whether it is select or a join request.
Try this in your GetById method:
var user.UserTags = dbContext.Entry(user)
.Collection(u => u.UserTags)
.Query()
.Where(ut => ut.Active == true)
.ToList();
The supplied code fails because it is attempting to remove items from the data entities not the list. If you want to pass the data entity around instead of the data model, you need to not use Remove. Something like the below (untested should work).
tags = item.UserTags.Where((ut) => ut.Active).ToList();
This line will get you a list of data entities that are active. However, you should really map all of this into a data model (see AutoMapper) and then you would not be removing items from the database.

updating a field on contact whenever a new event is created?

Here is the problem I'm trying to solve:
When a new TASK/EVENT is created, if the user is a certain profile - we want to update a field on CONTACT with the day the T/E was created.
I tried doing a workflow rule and field update- but I couldn't get it to work... I think since this is a Standard -Standard object relationship via lookup, it might have a problem doing a field update. Any other ideas?? I'd prefer to use the platform for this one...
HALP!
Thanks
We have done exactly what you are talking about via an Apex trigger. Something like this...
//I'm sure this doesn't compile, but it gives you the idea
trigger taskTrigger on Task( after insert, after update ){
Task t = trigger.new ;
Contact contact = [Select Id from Contact where Id = :t.whoId] ;
contact.yourfield = t.AcitivityDate ;
update contact ;
}

Update Multi-Picklist on updating custom object

I have custom object KeywordAccountAssociation__c. This object has three fields
Account__c - Master-Detail(Account)
Keyword__c - Master-Detail(Keyword)
Compositecp__c - Text(255) (External ID) (Unique Case Sensitive)
I have a custom field in Account
DD_Segment__c - multi-picklist
Now I want to update (Insert is fine too) values of DD_Segment__c whenever KeywordAccountAssociation__c is updated. I could write trigger for this but I don't know how? I am new to Salesforce Development and my background is ruby (so getting accustomed to apex is bit difficult for me).
KeywordAccountAssociation__c has multiple rows of Account__c which has same account_id and those account_id are related to a record of custom object Keyword__c. I want to get all keywords related to one account and update in its (account's) multi-picklist. How can I achieve this? If you have doubts about this please do ask. Thanks!
One issue is related to learning to work with triggers in general, which can be started with Salesforce Apex Developer Documents on Triggers
but to answer your actual question, you would essentially need to build a trigger against your custom object that would update the related account. It might look something like this:
trigger keywordAccountUpdate on KeywordAccountAssociation__c (after insert, after update){
set<id> = new set<id>();
for (KeywordAccountAssociation__c a : Trigger.new)
accountIds.put(a.Account__c);
map<id,Account> accountMap = new map<id,Account>([select id, DD_Segment__c from Account where id in :accountIds]);
for (KeywordAccountAssociation__c kaa : Trigger.new){
if (AccountMap.containskey(kaa.Account__c)){
Account thisAccount = AccountMap.get(kaa.Account__c);
String s = thisAccount.DD_Segment__c + ';new value'; // Always add value
if ((thisAccount.DD_Segment__c).contains('second value')
s += ';second value';
AccountsToUpdate.add(new Account(id=thisAccount.id, DD_Segment__c = s));
}
}
}
Please keep in mind that I don't have the structure to test this trigger, I just free handded it, so YMMV.

Cakephp:How to validate my select options so that it restricts duplication of options selected

I have a selection drop down menu, and I want the user to select two options for a field in the database. The problem is how do I make it to disallow duplication of select options, currently it's saving all options even when they are the same.
Code in my add.ctp for the select options is:
echo $this->Form->select("ProgrammeChoice.programme_code.0",$finals);
echo $this->Form->select("ProgrammeChoice.programme_code.1",$finals);
And the variable $finals is bringing the select options from another table in the database, it's in the controller and the code is:
$finals = array_merge($filtered_programs,$non_preq_programs);
So please, I want help to validate my select menu to deny duplicate selections on submission.
Create a custom validation rule and compare the values as described here: http://book.cakephp.org/2.0/en/models/data-validation.html#adding-your-own-validation-methods
In the validation method your data is stored in $this->data.
It should look similar to this:
public function compare($field1) {
if($field1 === $this->data['ProgrammeChoice']['programm_code']['1']) {
return false;
}
return true;
}

Zend Many to Many Relationship

I want to retrieve all the data from 3 tables
users , properties and users_properties.
So I decided I would use the manytomanyRowset. But to my surprise I get the data from the properties and users_properties table but no data from the users table. Why is that? I need some columns from the users table is there a way to tell the manytomanyrowset function that I need the data from the current table as well?
this is my function
public function fetchRegisteredProperties()
{
$userTable = $this->getTable();
require_once APPLICATION_PATH . '/models/DbTable/UsersPropertiesDB.php';
require_once APPLICATION_PATH . '/models/DbTable/PropertiesDB.php';
$propertiesRowset = $table->fetchAll();
$allProperties = array();
foreach ($propertiesRowset as $row) {
$propertiesRowset = $row->findManyToManyRowset(
'Model_DbTable_Properties','Model_DbTable_UsersProperties');
$allProperties = array_merge($tempArray,$propertiesRowset->toArray());
}
return $allProperties;
}
thanks in adavance
I designed and coded the table-relationships features in Zend Framework.
The answer to your question is no, the findManyToManyRowset() method only fetches rows from the related table, it does not merge them into the corresponding Row object. The reason is that a Row object in ZF can save() itself back to the database, and if you add fields it won't know what to do with them.
So you should implement a custom Row object to hold both user fields and the collection of user properties -- store the user properties as a Rowset object.
Then extend __get() and __set() so that it knows how to map fields into the correct array when you read or write object properties. That is, if one tries to read or write a field that isn't part of the user row, it falls back to the user properties Rowset.
Also extend save() to save not only the current row, but also call save() on the Rowset of user properties.

Resources