Validation rule in Oracle Sales Cloud - oracle

Sorry if this is the wrong place to ask, but I'm writing this validation rule in Oracle Sales Cloud 11 on the account object (field : Address Line 1), and it always returns false even if true, I don't get it. I've tried several formulations, but the issue remains, thanks a lot for your help.
if (PrimaryAddressLine1 == null) {
return false
}
else {
return true
}

Instead of putting the validation at object level, can you place the required/mandatory requirement by configuring in Manage Address Formats and handle it there. Making Address Line 1 required at this Level will make it required across objects where OOTB Address Section is used.

You can try the following code:
if (!PrimaryAddressLine1) {
return false } else {
return true }

Related

How to restrict SlickGrid to make a API call, while clicking or changing compound filters?

I have a SlickGrid Table, in which there are compound filters, currently when i try to change the compound filter (lets say from Equal To to Less Than), then it makes an API call.
I don't want to make an API call, how do i achieve this?
I searched in slickgrid docs, but couldn't find any property(if it is available).
Image
Please note that I'm the author of Angular-Slickgrid
So I looked at the problem you're having and it seems like a valid problem to look into, I agree that for some filters like the Compound Date Filter Operator we shouldn't query right away, that is after changing a the operator dropdown without providing a date. So, for that reason I am adding a new grid option skipCompoundOperatorFilterWithNullInput which will avoid triggering a filter change (it will also avoid querying the backend when implemented) when we first change the operator dropdown without providing a date being entered.
Note that this new option will only be available with Angular-Slickgrid v5.1.0+ (via this PR, now supports this and it will only be enabled by default on the Compound Date Filter (any other filters will have to explicitly enable this new flag either via grid option or via a column definition).
What if I cannot upgrade to 5.1.0? Are there any other ways of dealing with this?
Yes, it's just a bit more involving dealing with this though, it however requires a lot more work from your side. The information you need to know is that nearly every piece of code from Angular-Slickgrid and Slickgrid-Universal are protected TypeScript classes and functions which mean that you can simply use TypeScript to extends any of them. Let's take for example the CompoundDateFilter class, we could extend it this way to skip the callback triggering without a date provided (this._currentDate)
import { CompoundDateFilter, OperatorString } from '#slickgrid-universal/common';
export class CustomCompoundDateFilter extends CompoundDateFilter {
protected onTriggerEvent(e: Event | undefined) {
if (this._clearFilterTriggered) {
this.callback(e, { columnDef: this.columnDef, clearFilterTriggered: this._clearFilterTriggered, shouldTriggerQuery: this._shouldTriggerQuery });
this._filterElm.classList.remove('filled');
} else {
const selectedOperator = this._selectOperatorElm.value as OperatorString;
(this._currentValue) ? this._filterElm.classList.add('filled') : this._filterElm.classList.remove('filled');
// -- NEW CODE BELOW -- (to skip triggering callback on undefined date)
// when changing compound operator, we don't want to trigger the filter callback unless the date input is also provided
if (this._currentDate !== undefined) {
this.callback(e, { columnDef: this.columnDef, searchTerms: (this._currentValue ? [this._currentValue] : null), operator: selectedOperator || '', shouldTriggerQuery: this._shouldTriggerQuery });
}
}
this._clearFilterTriggered = false;
this._shouldTriggerQuery = true;
}
}
then use this new custom filter class in your column definitions
import { CustomCompoundDateFilter } from './custom-compoundDateFilter';
initGrid() {
this.columnDefinitions = [{
id: 'start', name: 'Start', field: 'start',
filterable: true, filter: { model: CustomCompoundDateFilter },
}];
}
and there you have it, below is a proof that it is working since I changed the operator and as you can see below this action is no longer resulting in 0 row returned. However if I had done the inverse, which is to input the date but without an operator, it would have execute the filtering because "no operator" is defaulting to the "equal to" operator.

Ember-validation how to implement lazy validation

I am using ember-cli:2.5.0 and ember-validations:v2.0.0-alpha.5
In my ember-component i have a validation which is running automatically for each change in a attribute but i want to run this validation only if i call "validate()" method in technical term call validation lazily.
Please find the below code samples,
import Ember from 'ember';
import EmberValidations, { validator } from 'ember-validations';
export default Ember.Component.extend(EmberValidations, {
didReceiveAttrs() {
this.set('newBook', this._bookModel().create());
},
_bookModel(data = {}) {
return Ember.Object.extend(EmberValidations, {
bookVersion: null,
isEditable: false,
validationActive: false,
validations: {
bookVersion: {
inline: validator(function() {
if(this.validationActive){ //Here this.validationActive always return undefined
var version = this.model.get('bookVersion') || "",
message = [];
if (Ember.isEmpty(bookVersion)) {
message.push("Book Version is mandatory!!!");
}
if (message.length > 0) {
return message.join(',');
}
}
})
}
}
}, data);
}
});
actions: {
this.get('newBook').set("validationActive",true);
this.get('newBook').validate().then(() => {
//Do the action
}
}
I want the above validation to run only calling "this.get('newBook').validate()". I am entirely new to ember so down-voter please put your comments before down-voting for others kindly let me know for any more code samples.
Your help should be appreciable.
The addon you are using for validations ("ember-validations") is a very popular one and its documentation is pretty well when compared to others. If you look at the documentation there is a part named "Conditional Validators" in documentation. You can use a boolean property to control when the validation is to be performed.
You can see an illustration of what I mean in the following twiddle. I have created a simple validation within the application controller for user's name. The name field must have a length of at least 5 and the validation is to be performed only if the condition validationActive is true. Initially; the condition is false; which means validator did not work and isValid property of Controller (which is inherited from EmberValidations Mixin) is true. If you toggle the property with the button provided; the validation will run (since the condition is now set to true; hence validation is triggered) and isValid will return to false. If you change the value; the validation result will change appropriately with respect to the value of user's name. If you toggle the condition once again to set it to false; then isValid will become true no matter what the valie of user's name is.
I hope this gives you an insight about how to control when your validations should work.
Here is what you should do after your edit: The field is undefined because you are trying to reach component's own validationActive field within inline validator. Please get validationActive as follows this.model.get('validationActive') and give a try. It should work.

Why is custom message not working in grails when tried with the following?

i am a beginner in grails and i have the following problem. Please help.
package racetrack
class Users {
String userName
String password
static constraints = {
userName(nullable:false, maxSize:20)
password(password:true, minSize: 8,
validator: {
return (it.matches("(.*[\\d])"))?true: ['noNumber']
return (it.matches("(.*[\\W])"))?true: ['noSpecialCh']
return (it.matches("(.*[a-z])"))?true: ['noLower']
return (it.matches("(.*[A-Z])"))?true: ['noUpper']
}
)
}
}
I created the above domain and in message.properties, i added the following:
users.password.validator.noNumber=should contain at least one number
users.password.validator.noLower=should contain at least one lower case letter as well
users.password.validator.noUpper=should contain number as well
users.password.validator.noSpecialCh=should contain number as well
however, i am not given required messages when tried with faulty values. Suppose, if i give no number in the password "should contain at least one number" message was expected but i only get does not match custom validation message.
The core problem is that Groovy, unlike Java, allows multiple return statements. If you converted that to Java it wouldn't compile.
Groovy allows multiple return statements, but obviously only considers the first, so with your code you have one check, not four, essentially
(it.matches("(.*[\\d])")) ? true : ['noNumber']
It should be something like this:
if (!it.matches("(.*[\\d])")) {
return ['noNumber']
}
if (!it.matches("(.*[\\W])")) {
return ['noSpecialCh']
}
if (!it.matches("(.*[a-z])")) {
return ['noLower']
}
if (!it.matches("(.*[A-Z])")) {
return ['noUpper']
}
except that all of the regexes are broken, but that's a separate issue.

Get room/rooms of client [duplicate]

I can get room's clients list with this code in socket.io 0.9.
io.sockets.clients(roomName)
How can I do this in socket.io 1.0?
Consider this rather more complete answer linked in a comment above on the question: https://stackoverflow.com/a/24425207/1449799
The clients in a room can be found at
io.nsps[yourNamespace].adapter.rooms[roomName]
This is an associative array with keys that are socket ids. In our case, we wanted to know the number of clients in a room, so we did Object.keys(io.nsps[yourNamespace].adapter.rooms[roomName]).length
In case you haven't seen/used namespaces (like this guy[me]), you can learn about them here http://socket.io/docs/rooms-and-namespaces/ (importantly: the default namespace is '/')
Updated (esp. for #Zettam):
checkout this repo to see this working: https://github.com/thegreatmichael/socket-io-clients
Using #ryan_Hdot link, I made a small temporary function in my code, which avoids maintaining a patch. Here it is :
function getClient(roomId) {
var res = [],
room = io.sockets.adapter.rooms[roomId];
if (room) {
for (var id in room) {
res.push(io.sockets.adapter.nsp.connected[id]);
}
}
return res;
}
If using a namespace :
function getClient (ns, id) {
return io.nsps[ns].adapter.rooms[id]
}
Which I use as a temporary fix for io.sockets.clients(roomId) which becomes findClientsSocketByRoomId(roomId).
EDIT :
Most of the time it is worth considering avoiding using this method if possible.
What I do now is that I usually put a client in it's own room (ie. in a room whose name is it's clientID). I found the code more readable that way, and I don't have to rely on this workaround anymore.
Also, I haven't tested this with a Redis adapter.
If you have to, also see this related question if you are using namespaces.
For those of you using namespaces I made a function too that can handle different namespaces. It's quite the same as the answer of nha.
function get_users_by_room(nsp, room) {
var users = []
for (var id in io.of(nsp).adapter.rooms[room]) {
users.push(io.of(nsp).adapter.nsp.connected[id]);
};
return users;
};
As of at least 1.4.5 nha’s method doesn’t work anymore either, and there is still no public api for getting clients in a room. Here is what works for me.
io.sockets.adapter.rooms[roomId] returns an object that has two properties, sockets, and length. The first is another object that has socketId’s for keys, and boolean’s as the values:
Room {
sockets:
{ '/#vQh0q0gVKgtLGIQGAAAB': true,
'/#p9Z7l6UeYwhBQkdoAAAD': true },
length: 2 }
So my code to get clients looks like this:
var sioRoom = io.sockets.adapter.rooms[roomId];
if( sioRoom ) {
Object.keys(sioRoom.sockets).forEach( function(socketId){
console.log("sioRoom client socket Id: " + socketId );
});
}
You can see this github pull request for discussion on the topic, however, it seems as though that functionality has been stripped from the 1.0 pre release candidate for SocketIO.

Restrict Google Places Autocomplete to return addresses only

autocomplete = new google.maps.places.Autocomplete(input, { types: ['geocode'] });
returns streets and cities amongst other larger areas. Is it possible to restrict to streets only?
This question is old, but I figured I'd add to it in case anyone else is having this issue. restricting types to 'address' unfortunately does not achieve the expected result, as routes are still included. Thus, what I decided to do is loop through the result and implement the following check:
result.predictions[i].types.includes('street_address')
Unfortunately, I was surprised to know that my own address was not being included, as it was returning the following types: { types: ['geocode', 'premise'] }
Thus, I decided to start a counter, and any result that includes 'geocode' or 'route' in its types must include at least one other term to be included (whether that be 'street_address' or 'premise' or whatever. Thus, routes are excluded, and anything with a complete address will be included. It's not foolproof, but it works fairly well.
Loop through the result predictions, and implement the following:
if (result.predictions[i].types.includes('street_address')) {
// Results that include 'street_address' should be included
suggestions.push(result.predictions[i])
} else {
// Results that don't include 'street_address' will go through the check
var typeCounter = 0;
if (result.predictions[i].types.includes('geocode')) {
typeCounter++;
}
if (result.predictions[i].types.includes('route')) {
typeCounter++;
}
if (result.predictions[i].types.length > typeCounter) {
suggestions.push(result.predictions[i])
}
}
I think what you want is { types: ['address'] }.
You can see this in action with this live sample: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete (use the "Addresses" radio button).

Resources