sugarcrm editview coding help for newbi - java

I have an older version of sugarcrm 4.5 running.
Dont brake that aint broken.
I have a script i wrote that adds 30 days from current date to expected close date when creating a new opportunity, but the problem is everytime you edit the opportunity it adds 30 days, and not just when its is new. How do i tel Sugar to only look for new. this is in editview.php not a logic hook as i want to display the date in the field when creating.
Heres my code
var currentTime = new Date();
document.getElementsByName('date_closed')[0].value = (year = currentTime.getFullYear())+'-'+(month = currentTime.getMonth() + 2)+'-'+(day = currentTime.getDate());
regards

This should be done with a before save logic hook - you can test to see if the record has an id in the hook. If it has no id then you can assume its a new record.
More information on logic hooks can be found here (you are using a very old version of SugarCRM so not everything in this documentation will apply)
http://developers.sugarcrm.com/docs/OS/5.2/-docs-Developer_Guides-Developer_Guide_5.2-DevGuide%205.2.1.47.html

Related

Scichart's setVisibleRange() having no effect

I'm trying to set the visible range of a DateAxis. Here's what I have:
final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build();
final IAxis xBottomAxis = sciChartBuilder.newDateAxis()
.withAxisId("xBottomAxis")
.build();
xBottomAxis.setAutoRange(AutoRange.Never);
xBottomAxis.setTextFormatting("MM.dd.yyyy h:mm a");
Calendar rightNow = Calendar.getInstance();
long t = rightNow.getTimeInMillis();
Date rightNowPlusFiveMin = new Date(t + (5 * ONE_MINUTE_IN_MILLIS));
Date rightNowMinusThreeHr = new Date(t - (3 * ONE_HOUR_IN_MILLIS));
xBottomAxis.setVisibleRange(new DateRange(rightNowMinusThreeHr, rightNowPlusFiveMin));
This should keep it from AutoRanging and set the default min and max on the xBottomAxis. Is this not how you do it?
Currently, it's just AutoRanging to fit the data.
Edit: Here are the applicable links for its documentation.
https://www.scichart.com/documentation/android/v2.x/webframe.html#Axis%20Ranging%20-%20VisibleRange%20and%20DataRange.html
https://www.scichart.com/documentation/android/v2.x/webframe.html#Axis%20Ranging%20-%20Setting%20and%20Getting%20VisibleRange.html
I tried to copy-paste your code in this example and it worked as expected - axis was rendered with assigned VisibleRange value.
I noticed that you used custom AxisId for your DateAxis. Does it mean that you have more than one XAxis and maybe your RenderableSeries is attached to wrong axis?
Also I would suggest you to update to the latest version of the library - it could be possible that if it's a bug then it's already fixed in latest build.
If it doesn't help then you'll need to provide more code or entire project which reproduces this issue because with code which you provided it's hard to tell what could be the cause of this issue.
It looks like removing mySciChartSurface.zoomExtents() fixed it. Link to zoomExtents documentation.
Thanks to Yura Khariton for the help.

How to report a bug in Office 365 Android SDK

I was pointed at Stack Overflow by Microsoft support as the place to get help about the Office 365 Android SDK, including how to report bugs.
I'm finding that a call to Item.getDateTimeLastModified() will consistently return an incorrect date/time. Most of the time, if an item has been recently updated, it will return a millisecond value (in the GMT time zone) that is anything up to 2 hours and a few minutes ahead of current GMT.
Other date times such as Event.getStart()/Event.getEnd() are returning the correct values.
When processing calendar events I am using the following to retrieve events:
ListenableFuture<List<Event>> eventsGet = this.userFetcher
.getCalendar (this.calendarId)
.getEvents ()
.top (pageSize)
.skip (skip)
.select ("Id")
.filter (modFromDate)
.orderBy ("DateTimeLastModified")
.read ();
List<Event> events = eventsGet.get (60,
TimeUnit.SECONDS);
Then I process the events one at a time and using the id get the actual event using:
this.userFetcher.getCalendar (this.calendarId).getEvent (id).read ().get (60, TimeUnit.SECONDS);
Calling getDateTimeLastModified on that event will return the strange value.
I can provide calendar/event ids if required.
As an aside, I notice that the Office.com calendar when it retrieves the json data for the event has the correct last modified time.
You can submit bugs/issues on the Office 365 SDK for Android on the GitHub page where the project is hosted.
I'm Anahí from the Office 365 SDK for Android team.
We've created an issue with your problem in our GitHub repository and will start reviewing it. We'll post the updates there once the error is fixed.
https://github.com/OfficeDev/Office-365-SDK-for-Android/issues/86
The GitHub repo is the best place to submit bugs/issues since we're reviewing it all the time.
Thanks!

Google Calendar API w/ Java - Get events only for the default calendar, ignoring the holidays

What I am trying to do is get a list of all the events in the default calendar only? I don't want any other calendars' events included, i.e., holidays.
I am using the ".../feeds/username/default/full" and doing a query for all events from 1 month ago to forever. I have two events that I have created but I get a feed with 25 entries. My two events first and then 23 holidays. I really don't them to be included at all but if them MUST be there, how do I detect them. The only thing I can find is the eTag for my two events is different from the holiday ones. But I can't just say get all the events from the first Etag I encounter because the default calendar may not have any events so the first one would be holidays.
Any help would be appreciated.
This can be done with a few lines of code using the latest version of the Google Calendar API. All you need to do is pull the events for the primary calendar, as documented here:
http://code.google.com/apis/calendar/v3/using.html#retrieving_events
The code you need is:
Events events = service.events().list("primary").execute();
while (true) {
for (Event event : events.getItems()) {
System.out.println(event.getSummary());
}
String pageToken = events.getNextPageToken();
if (pageToken != null && !pageToken.isEmpty()) {
events = service.events().list("primary").setPageToken(pageToken).execute();
} else {
break;
}
}
I wonder what version of the Calendar API you are using? In v3 I am able to all my events without getting the holidays. I added some more code examples, since the Google documentation is incorrect for connecting to the Calendar V3 API though Oauth2 for Java.
Use the code listed in the other post to loop though the Calendar events after the Oauth is setup and the Calendar is initialized. You probably can, but do not need to declare the events API. I just call it from the Calendar service(3). Note the Calendar ID I have listed is "Primary."
Calendar service3 = new Calendar(transport, jsonFactory, accessProtectedResource);
com.google.api.services.calendar.model.Calendar calendar = service3.calendars().get("primary").execute();
com.google.api.services.calendar.model.Events events = service3.events().list("primary").execute();

Filter emails by date using hours and minutes

I'm trying to get all mail that I receive after some date. But folder.search( returns all of them. Even if I specify ComparisonTerm.EQ
Folder folder = getInboxFolder();
ReceivedDateTerm dateTerm = new ReceivedDateTerm(ComparisonTerm.EQ, new Date());
Message[] messages = folder.search(dateTerm);
How I should correct my code?
UPD It seems that it make job right with year/month/day comparation, but what about hours and minutes? I should care about them too.
Unfortunally looks like it's not possible to do so. check this thread: Click here!

Connecting Java with Google Calendar

I'm relatively new to Java, so I have little to no idea where to even start with this one. I'm writing a scheduling application using Java and google calendars. On my google account I have a bunch of calendars with people's schedules on them. I need to access these calendars through java and insert the person's free / busy information into arrays like so:
//User 1
int[][] swift_schedule = new int[5][6];
//1 = busy, 0 = free
//Monday
swift_schedule[0][0] = 0; //9-11
swift_schedule[0][1] = 1; //11-1
swift_schedule[0][2] = 1; //1-3
swift_schedule[0][3] = 1; //3-5
swift_schedule[0][4] = 1; //5-7
swift_schedule[0][5] = 1; //7-9
//Tuesday
swift_schedule[1][0] = 0; //9-11
swift_schedule[1][1] = 0; //11-1
swift_schedule[1][2] = 0; //1-3
etc....
If I were using PHP, I would get a url for the XML feed and just parse the data out of it, but with JAVA I don't even know where to start. Can anyone point me in the right direction? Tutorials, code snippets, and other hints would be greatly appreciated!
cheers,
Mike
You don't have to do the parsing when there is a Java API for it, simply use it and query for the calendar events you want.
With DateTime and CalendarQuery you can query for events in a specific time interval (your use case: to get events in a give day).
CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(DateTime.parseDateTime("2006-03-16T00:00:00"));
myQuery.setMaximumStartTime(DateTime.parseDateTime("2006-03-24T23:59:59"));
Google Calendar allows client
applications to view and update
calendar events in the form of Google
Data API feeds. Your client
application can use the Google
Calendar Data API to create new
events, edit or delete existing
events, and query for events that
match particular criteria.

Categories

Resources